Bug 842773 - Zoneminder fails at startup
Zoneminder fails at startup
Product: Fedora
Classification: Fedora
Component: zoneminder (Show other bugs)
x86_64 Linux
unspecified Severity high
: ---
: ---
Assigned To: Martin Ebourne
Fedora Extras Quality Assurance
Depends On:
  Show dependency treegraph
Reported: 2012-07-24 10:58 EDT by Jonn Taylor
Modified: 2014-11-20 19:41 EST (History)
6 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2013-07-31 20:23:31 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Jonn Taylor 2012-07-24 10:58:14 EDT
Description of problem:

Zoneminder fails to start due to the fact that mysql is not ready to accept connection. Looks they are started at the same time.

Jul 22 20:13:33 dvr mysqld_safe[1116]: 120722 20:13:33 mysqld_safe Logging to '/var/log/mysqld.log'.
Jul 22 20:13:33 dvr zoneminder[1075]: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)
Jul 22 20:13:33 dvr mysqld_safe[1116]: 120722 20:13:33 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Jul 22 20:13:35 dvr zoneminder[1075]: Starting ZoneMinder: DBI connect('database=zm;host=localhost','zmuser',...) failed: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) at /usr/share/perl5/vendor_perl/ZoneMinder/Config.pm line 89
Jul 22 20:13:35 dvr zoneminder[1075]: Can't call method "prepare_cached" on an undefined value at /usr/share/perl5/vendor_perl/ZoneMinder/Config.pm line 91.
Jul 22 20:13:35 dvr zoneminder[1075]: BEGIN failed--compilation aborted at /usr/share/perl5/vendor_perl/ZoneMinder/Config.pm line 100.
Jul 22 20:13:35 dvr zoneminder[1075]: Compilation failed in require at /usr/share/perl5/vendor_perl/ZoneMinder.pm line 33.
Jul 22 20:13:35 dvr zoneminder[1075]: BEGIN failed--compilation aborted at /usr/share/perl5/vendor_perl/ZoneMinder.pm line 33.
Jul 22 20:13:35 dvr zoneminder[1075]: Compilation failed in require at /usr/bin/zmpkg.pl line 46.
Jul 22 20:13:35 dvr zoneminder[1075]: BEGIN failed--compilation aborted at /usr/bin/zmpkg.pl line 46.
Jul 22 20:13:35 dvr zoneminder[1075]: [FAILED]
Jul 22 20:13:35 dvr systemd[1]: zoneminder.service: control process exited, code=exited status=255
Jul 22 20:13:35 dvr systemd[1]: Unit zoneminder.service entered failed state.
Comment 1 Jason Tibbitts 2012-07-24 11:10:03 EDT
Try adding an After= ordering clause to the service file and see if it helps.
Comment 2 Jonn Taylor 2012-07-24 11:13:08 EDT
Zoneminder still uses init file located in /etc/inid.d/zoneminder.
Comment 3 Jason Tibbitts 2012-07-24 12:26:01 EDT
Hm, indeed, it uses systemd in rawhide but not f17.

I am not sure there's anything that can be done here.  When mysql was using initscripts the ordering was correct.  With everything using systemd the ordering appears to be correct (or at least it worked OK in my testing, though I will double check).  But I do not know if there is a way to enforce ordering between services using the old and new startup methods.  At this point all I can really suggest is that you work around the issue by adding a sleep to the zoneminder initscript, though I'll be happy to look at any other options.
Comment 4 Jonn Taylor 2012-07-24 13:57:36 EDT
How about an updated packaged for fc17 to use systemd? or can I rebuild the src package from rawhide and use it on fc17?
Comment 5 Jonn Taylor 2012-07-24 14:15:56 EDT
Adding a sleep 10 to the init script gave mysql time to complete startup.

	sleep 10
	zmupdate || return $?
	loadconf || return $?
	#Make sure the directory for our PID folder exists or create one.
	[ ! -d $pidfile ] \
		&& mkdir -m 774 $pidfile \
		&& chown $ZM_WEB_USER:$ZM_WEB_GROUP $pidfile
	#Make sure the folder for the socks file exists or create one
	GetPath="select Value from Config where Name='ZM_PATH_SOCKS'"
    dbHost=`echo $ZM_DB_HOST | cut -d: -f1`
    dbPort=`echo $ZM_DB_HOST | cut -d: -s -f2`
    if [ "$dbPort" = "" ]
	    ZM_PATH_SOCK=`echo $GetPath | mysql -B -h$ZM_DB_HOST -u$ZM_DB_USER -p$ZM_DB_PASS $ZM_DB_NAME | grep -v '^Value'`
	    ZM_PATH_SOCK=`echo $GetPath | mysql -B -h$dbHost -P$dbPort -u$ZM_DB_USER -p$ZM_DB_PASS $ZM_DB_NAME | grep -v '^Value'`
	[ ! -d $ZM_PATH_SOCK ] \
		&& mkdir -m 774 $ZM_PATH_SOCK \
	echo -n $"Starting $prog: "
	$command start
	[ $RETVAL = 0 ] && success || failure
	[ $RETVAL = 0 ] && touch $LOCKFILE
	return $RETVAL
Comment 6 Jason Tibbitts 2012-07-24 14:58:02 EDT
Updating a package from sysv to systemd is not permitted within a Fedora release.  You are welcome to rebuild the F18 source package for F17 if you like.  If I was at my dev station instead of on vacation here at one of the far ends of the Earth, I'd do a build for you.
Comment 7 Axel Mammes 2013-02-01 11:42:37 EST
This problem persists in F18 and I am struggling with it right now. 

Since zm connects via unix sockets, is there a way to tell systemd to wait for the mysqld socket to exist before trying to start zm?
Comment 8 Jason Tibbitts 2013-02-01 11:53:12 EST
I guess mysql could use socket activation.  I don't know; that's really something that should be taken up with the mysq1 maintainers.  Dealing with this issue is supposed to be one of the reasons systemd was created, but I'm not really the person to ask about that.
Comment 9 Axel Mammes 2013-02-01 12:24:39 EST
The system.d startup profile for zm is part of the zm rpm. I really don't think the mysql guys have anything to do with this fix.
Comment 10 Jason Tibbitts 2013-02-01 12:38:52 EST
I'm glad that's what you think, but unfortunately you are not correct.  If mysql wants to make use of the systemd socket activation feature, where clients can connect and systemd will simply hold their connections until mysql actually starts up, then the mysql maintainers are going to have to do that.  It's nothing I can do in zoneminder.
Comment 11 Axel Mammes 2013-02-01 13:39:34 EST
After adding After and Requires entries to /etc/systemd/system/multi-user.target.wants/zoneminder.service, zm starts up properly.

Description=Video security and surveillance system

ExecStart=/usr/bin/zmpkg.pl start
ExecReload=/usr/bin/zmpkg.pl reload

Comment 12 Bill Gradwohl 2013-05-29 11:16:01 EDT

This is just an FYI.

I tried your fix on a fully patched F17 and it doesn't work for me. 

There was no zoneminder.service file in multi-user.target.wants, so I just created it. Don't know enough about systemd to really know what I did.

When I execute a systemctl enable for this it still segways to chkconfig, so what I have is still not part of a REAL systemd setup.
Comment 13 Fedora End Of Life 2013-07-03 18:27:40 EDT
This message is a reminder that Fedora 17 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 17. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '17'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 17's end of life.

Bug Reporter:  Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 17 is end of life. If you 
would still like  to see this bug fixed and are able to reproduce it 
against a later version  of Fedora, you are encouraged  change the 
'version' to a later Fedora version prior to Fedora 17's end of life.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.
Comment 14 Fedora End Of Life 2013-07-31 20:23:35 EDT
Fedora 17 changed to end-of-life (EOL) status on 2013-07-30. Fedora 17 is 
no longer maintained, which means that it will not receive any further 
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of 
Fedora please feel free to reopen this bug against that version.

Thank you for reporting this bug and we are sorry it could not be fixed.
Comment 15 Bill Gradwohl 2013-09-15 19:22:40 EDT
I just installed zoneminder on a fully patched F19, and it still exhibits the failure as described above. However, the fix to add:


to /etc/systemd/system/multi-user.target.wants/zoneminder.service also as described above works.

I just wanted someone to know that adding those 2 lines to that file fixes the problem.
Comment 16 Walter Francis 2014-11-20 19:41:09 EST
This was happening on 18, 19, 20..  Maybe it'll get a fix in 21?

Note You need to log in before you can comment on or make changes to this bug.