Description of problem: I need help with this. ZoneMinder has a web interface feature which allows starting and stopping the service. The service is normally started by systemd. If the service is stopped and re-started from the web interface then systemd control is lost. To help debug this I wrote a small script that fills an array with all the zm* process IDs and then displays the process name, the ps aux o/p for that process and cat /proc/$ID/cgroup output. There are typically seven such processes, but the pattern is the same for all, so picking just one:- When started by systemd:- zmupdate.pl apache 20411 0.4 1.6 169348 16752 ? S 19:46 0:00 /usr/bin/perl -w /usr/bin/zmupdate.pl -c 7:blkio:/ 6:net_cls:/ 5:freezer:/ 4:devices:/ 3:cpuacct,cpu:/system/zoneminder.service 2:cpuset:/ 1:name=systemd:/system/zoneminder.service ################################################################################# Same process after being stopped and started from the web interface:- zmupdate.pl apache 20001 0.1 1.6 169348 16748 ? S 19:33 0:00 /usr/bin/perl -w /usr/bin/zmupdate.pl -c 7:blkio:/ 6:net_cls:/ 5:freezer:/ 4:devices:/ 3:cpuacct,cpu:/system/httpd.service 2:cpuset:/ 1:name=systemd:/system/httpd.service ################################################################################## It appears to have switched to (or inherited) httpd.service. I have spent hours reading about systemd and cgroups, but the more I read the less I realize I know :( ################################################################################## Trying to restart the service with systemctl produces the following :- [root@jackodesktop baz]# systemctl restart zoneminder.service Job failed. See system journal and 'systemctl status' for details. [root@jackodesktop baz]# systemctl status zoneminder.service zoneminder.service - ZoneMinder CCTV recording and security system Loaded: loaded (/lib/systemd/system/zoneminder.service; disabled) Active: failed (Result: exit-code) since Fri, 15 Jun 2012 18:17:29 +0100; 2min 17s ago Process: 18571 ExecStart=/usr/bin/zmpkg.pl start (code=exited, status=1/FAILURE) CGroup: name=systemd:/system/zoneminder.service Jun 15 18:17:28 jackodesktop zmpkg[18571]: INF [Command: start] ################################################################################## After stopping the service from the web interface :- [root@jackodesktop baz]# systemctl restart zoneminder.service (no errors) [root@jackodesktop baz]# systemctl status zoneminder.service zoneminder.service - ZoneMinder CCTV recording and security system Loaded: loaded (/lib/systemd/system/zoneminder.service; disabled) Active: active (running) since Fri, 15 Jun 2012 18:22:32 +0100; 6s ago Process: 18681 ExecStart=/usr/bin/zmpkg.pl start (code=exited, status=0/SUCCESS) Main PID: 18702 (zmdc.pl) CGroup: name=systemd:/system/zoneminder.service â 18702 /usr/bin/perl -wT /usr/bin/zmdc.pl startup â 18728 /usr/bin/zmc -d /dev/video0 â 18740 /usr/bin/perl -wT /usr/bin/zmfilter.pl â 18752 /usr/bin/zma -m 1 â 18760 /usr/bin/perl -wT /usr/bin/zmaudit.pl -c â 18768 /usr/bin/perl -wT /usr/bin/zmwatch.pl â 18780 /usr/bin/perl -w /usr/bin/zmupdate.pl -c Jun 15 18:22:32 jackodesktop zmdc[18780]: INF ['zmupdate.pl -c' started at 12/06/15 18:22:32] Jun 15 18:22:32 jackodesktop zmwatch[18768]: INF [Watchdog starting] Jun 15 18:22:32 jackodesktop zmwatch[18768]: INF [Watchdog pausing for 30 seconds] Jun 15 18:22:35 jackodesktop zma_m1[18752]: INF [Monitor-1: 047 - Gone into alarm state] Jun 15 18:22:35 jackodesktop zma_m1[18752]: INF [Monitor-1: 047 - Opening new event 179, alarm start] Jun 15 18:22:36 jackodesktop zma_m1[18752]: INF [Monitor-1: 057 - Gone into alert state] Jun 15 18:22:36 jackodesktop zma_m1[18752]: INF [Monitor-1: 059 - Gone back into alarm state] Jun 15 18:22:37 jackodesktop zma_m1[18752]: INF [Monitor-1: 065 - Gone into alert state] Jun 15 18:22:37 jackodesktop zma_m1[18752]: INF [Monitor-1: 069 - Gone back into alarm state] Jun 15 18:22:38 jackodesktop zma_m1[18752]: INF [Monitor-1: 078 - Gone into alert state] (Which is all OK) #################################################################### Any help fixing this will be appreciated. Barry. Steps to Reproduce: 1. Install zoneminder 2. Run zmsetup to set up and start a basic installation 3. Go to the web interface and stop the service (top of screen) 4. Try to re-start the process using systemctl start zoneminder.service
CC: (none) => mageiaWhiteboard: (none) => MGA2TOO
I forgot to include the current unit file:- [Unit] Description=ZoneMinder CCTV recording and security system After=network.target mysqld.service httpd.service Requires=mysqld.service httpd.service [Service] User=apache Type=forking ExecStart=/usr/bin/zmpkg.pl start ExecStop=/usr/bin/zmpkg.pl stop [Install] WantedBy=multi-user.target
@ Barry You might want to ping Colin on IRC :)
CC: (none) => marja11Whiteboard: MGA2TOO => OK MGA2TOO NEEDHELP
So basically what this requires is a dbus policy rule that allows the apache user to call "systemctl restart zoneminder.service" (or there may be some policy kit stuff instead) I'm not 100% sure what this dbus policy rule will look like, but it shouldn't be too hard to figure out. I'll speak to upstream to make sure this is possible before looking too indepth.
Thanks Colin - I didn't want to hassle you on irc as I know how busy you are. I suspect that the zoneminder web UI will be calling zmpkg.pl directly as it knows nothing about systemd. I'm also guessing that we need a way for systemd to detect that the processes have been stopped/started by the web scripts and not by systemctl.
@ barjac Is this bug still valid? If not, then please close it ;-)
Whiteboard: OK MGA2TOO NEEDHELP => OK NEEDHELP
So basically, the dbus policy thing probably won't work and even if it did, it'll be due to change in the future with kdbus. I guess what I'd recommend now is using a policykit policy to allow systemctl or an appropriate wrapper script to be run via pkexec (without any password). This could then be patched into Zone Minder as the restart option. If you want a hand, I can take a look.
(In reply to Colin Guthrie from comment #6) > If you want a hand, I can take a look. Yes please Colin, your expertise would be very welcome :)
Colin - could you please cast your eye over this pull request: https://github.com/ZoneMinder/ZoneMinder/pull/474 which has been done by one of the ZoneMinder developers to address this issue following your advice in comment #6.
Summary: zoneminder systemd/cgroup problem => zoneminder systemd integration
Thanks for the ping Barry and sorry for not getting around to doing anything about it myself. Commented on the PR. tl;dr: It looks good to me.
Yes - I have have not had time to learn enough to do it either, but this works fine in a test build here, so I will incorporate it in the next release to 1.27.1 or sooner in a snapshot if it gets too close to mga5 release. Thanks again for your input :)
Whiteboard: OK NEEDHELP => (none)
Fixed upstream now so closing.
Status: NEW => RESOLVEDResolution: (none) => FIXED