Zoneminder service not starting at system boot

Forum for questions and support relating to the 1.24.x releases only.
Locked
theforce
Posts: 129
Joined: Tue May 11, 2010 5:22 am

Zoneminder service not starting at system boot

Post by theforce »

Everything was working perfectly fine until I updated the my system about a week ago. After I installed the security updates and rebooted the zoneminder service did not start automatically. If I ssh into the box and do a "sudo service zoneminder start" everything works fine.

I'm running Ubuntu 10.04. Since I'm still learning Linux I'm not sure on how to find out why this service is not starting. Can anyone help me figure this out?
Flash_
Posts: 441
Joined: Wed Jan 11, 2006 12:19 pm

Post by Flash_ »

It appears that ubuntu has a special habit of trying to start zoneminder too quickly after starting mysql, resulting in zm being unable to contact the database and quitting.

To verify, "dmesg|more" and look at the times on the left between mysql and zoneminder's start.
theforce
Posts: 129
Joined: Tue May 11, 2010 5:22 am

Post by theforce »

I dont see anything for zoneminder listed. I do see some things for mysql. Here is the last few lines.

[ 11.513422] bttv0: PLL: 28636363 => 35468950 .. ok
[ 12.982011] type=1505 audit(1282865788.873:5): operation="profile_load" pid=558 name="/usr/share/gdm/guest-session/Xsession"
[ 12.991276] type=1505 audit(1282865788.881:6): operation="profile_replace" pid=562 name="/sbin/dhclient3"
[ 12.991957] type=1505 audit(1282865788.881:7): operation="profile_replace" pid=562 name="/usr/lib/NetworkManager/nm-dhcp-client.action"
[ 13.006770] type=1505 audit(1282865788.897:8): operation="profile_replace" pid=562 name="/usr/lib/connman/scripts/dhclient-script"
[ 13.084294] type=1505 audit(1282865788.977:9): operation="profile_load" pid=567 name="/usr/bin/evince"
[ 13.093584] type=1505 audit(1282865788.985:10): operation="profile_load" pid=567 name="/usr/bin/evince-previewer"
[ 13.099272] type=1505 audit(1282865788.989:11): operation="profile_load" pid=567 name="/usr/bin/evince-thumbnailer"
[ 13.314426] type=1505 audit(1282865789.205:12): operation="profile_load" pid=569 name="/usr/lib/cups/backend/cups-pdf"
[ 13.315207] type=1505 audit(1282865789.205:13): operation="profile_load" pid=569 name="/usr/sbin/cupsd"
[ 13.407488] type=1505 audit(1282865789.301:14): operation="profile_load" pid=575 name="/usr/sbin/mysqld"
[ 13.427910] type=1505 audit(1282865789.317:15): operation="profile_load" pid=576 name="/usr/sbin/tcpdump"
[ 19.740937] eth1: link up, 100Mbps, full-duplex, lpa 0x45E1
[ 19.906944] type=1505 audit(1282865795.797:16): operation="profile_replace" pid=773 name="/usr/sbin/mysqld"
[ 25.403256] ppdev: user-space parallel port driver
[ 30.416043] eth1: no IPv6 routers present
[ 103.457578] bttv0: PLL can sleep, using XTAL (28636363).
Flasheart
Posts: 342
Joined: Thu Jul 06, 2006 2:27 pm

Post by Flasheart »

Sorry, I got the wrong logfile.

grep mysqld /var/log/syslog

grep zmpkg /var/log/syslog

(zmpkg is the zoneminder control script)

Both give start messages like

Aug 27 13:37:09 trumpton mysqld[2322]: 100827 13:37:09 [Note] /usr/sbin/mysqld: ready for connections.

Aug 27 13:37:41 trumpton zmpkg[2705]: INF [Command: start]

On mine there, there is a goodly time between sql starting and zoneminder starting. If they're too close and zm is started before sql is ready to listen, zm will bomb out because it can't find a sql server with errors like;

Aug 28 06:20:28 trumpton zma_m9[5761]: ERR [Can't insert event: MySQL server has gone away]
theforce
Posts: 129
Joined: Tue May 11, 2010 5:22 am

Post by theforce »

This is what I get for mysqld

Aug 28 23:15:18 garage zms[13115]: ERR [Can't connect to server: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)]

Aug 28 23:16:17 garage kernel: [ 33.099463] type=1505 audit(1283051777.985:14): operation="profile_load" pid=587 name="/usr/sbin/mysqld"

Aug 28 23:16:18 garage zmfix[766]: ERR [Can't connect to server: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)]


I get nothing with zmpkg

Now after I run "service zoneminder start" and then run the zmpkg I get a line...

Aug 28 23:21:54 garage zmpkg[2713]: INF [Command: start]
Flash_
Posts: 441
Joined: Wed Jan 11, 2006 12:19 pm

Post by Flash_ »

Hmm, Ubuntu does something different then. That zmfix error is almost certainly the reason why zm isn't starting. I don't know Ubuntu well so can't help with the specifics, but it may be worth you trying to change the start order of the programs, starting zm further behind mysqld, or adding a sleep(20) in the zm start script to make it wait until sql is there.

Could always remove zm and reinstall. Do a dump of the zm database to preserve your settings and events.
theforce
Posts: 129
Joined: Tue May 11, 2010 5:22 am

Post by theforce »

Just happened to see this post

http://www.zoneminder.com/forums/viewtopic.php?t=16298

and added the sleep 15 to the file and it fixed my problem.

Thanks for your help.
Flash_
Posts: 441
Joined: Wed Jan 11, 2006 12:19 pm

Post by Flash_ »

Great. I'll add it to the faq as it seems Ubuntu is a bit broken here.
SquALeD
Posts: 15
Joined: Wed Mar 17, 2010 5:30 am

Post by SquALeD »

theforce wrote:Just happened to see this post

http://www.zoneminder.com/forums/viewtopic.php?t=16298

and added the sleep 15 to the file and it fixed my problem.

Thanks for your help.
Hi guys. I take it you mean this line:

echo -n "Starting $Prog "

Where would I add the sleep 15 ?

Cheers - Sq
Locked