Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zmeventnotification continues to look for memory map file when zoneminder is shutting down #417

Open
eRaid6 opened this issue Jul 18, 2022 · 2 comments

Comments

@eRaid6
Copy link

eRaid6 commented Jul 18, 2022

Event Server version

$ /usr/bin/zmeventnotification.pl --version
6.1.28

Hooks version (if you are using Object Detection)

$ /var/lib/zmeventnotification/bin/zm_detect.py --version
app:6.1.28, pyzm:0.3.56

The version of ZoneMinder you are using:
1.36.20

OS version:
Ubuntu 20.04.4 LTS

What is the nature of your issue
Bug

Details
When zoneminder is told to restart via systemd, zmeventnotification.pl does not exit which causes Zoneminder restart to timeout. During this time if you manually kill zmeventnotification.pl then Zoneminder will restart successfully. Looks to be the same issue this person on the Zoneminder forums reported https://forums.zoneminder.com/viewtopic.php?t=30555.

Debug Logs (if applicable)

Jul 18 11:39:21 zoneminder systemd[1]: Stopping ZoneMinder CCTV recording and surveillance system...
Jul 18 11:39:22 zoneminder sudo[631772]:     root : TTY=unknown ; PWD=/usr/share/zoneminder/www ; USER=www-data ; COMMAND=/bin/true
Jul 18 11:39:22 zoneminder sudo[631772]: pam_unix(sudo:session): session opened for user www-data by (uid=0)
Jul 18 11:39:22 zoneminder sudo[631772]: pam_unix(sudo:session): session closed for user www-data
Jul 18 11:39:22 zoneminder sudo[631774]:     root : TTY=unknown ; PWD=/usr/share/zoneminder/www ; USER=www-data ; COMMAND=/usr/bin/zmdc.pl check
Jul 18 11:39:22 zoneminder sudo[631774]: pam_unix(sudo:session): session opened for user www-data by (uid=0)
Jul 18 11:39:22 zoneminder sudo[631774]: pam_unix(sudo:session): session closed for user www-data
Jul 18 11:39:22 zoneminder sudo[631777]:     root : TTY=unknown ; PWD=/usr/share/zoneminder/www ; USER=www-data ; COMMAND=/usr/bin/zmdc.pl shutdown
Jul 18 11:39:22 zoneminder sudo[631777]: pam_unix(sudo:session): session opened for user www-data by (uid=0)
Jul 18 11:39:23 zoneminder zmeventnotification[631142]: ERR [Shared data not valid for monitor 7]
Jul 18 11:39:23 zoneminder zmeventnotification[631142]: ERR [|----> FORK:garage (7), eid:315940 SHM failed, re-validating it]
Jul 18 11:39:23 zoneminder zmeventnotification[631142]: ERR [Memory map file '/dev/shm/zm.mmap.7' does not exist in zmMemAttach.  zmc might not be running.]
Jul 18 11:39:24 zoneminder sudo[631777]: pam_unix(sudo:session): session closed for user www-data
Jul 18 11:39:24 zoneminder zmeventnotification[631142]: ERR [Memory map file '/dev/shm/zm.mmap.7' does not exist in zmMemAttach.  zmc might not be running.]
Jul 18 11:39:24 zoneminder zmeventnotification[631142]: ERR [|----> FORK:garage (7), eid:315940 SHM failed, re-validating it]
Jul 18 11:39:24 zoneminder zmeventnotification[631142]: ERR [Memory map file '/dev/shm/zm.mmap.7' does not exist in zmMemAttach.  zmc might not be running.]
Jul 18 11:39:24 zoneminder zmeventnotification[631142]: ERR [Memory map file '/dev/shm/zm.mmap.7' does not exist in zmMemAttach.  zmc might not be running.]
Jul 18 11:39:24 zoneminder zmeventnotification[631142]: ERR [|----> FORK:garage (7), eid:315940 SHM failed, re-validating it]
Jul 18 11:39:24 zoneminder zmeventnotification[631142]: ERR [Memory map file '/dev/shm/zm.mmap.7' does not exist in zmMemAttach.  zmc might not be running.]
Jul 18 11:39:26 zoneminder zmeventnotification[631142]: ERR [Memory map file '/dev/shm/zm.mmap.7' does not exist in zmMemAttach.  zmc might not be running.]
Jul 18 11:39:26 zoneminder zmeventnotification[631142]: ERR [|----> FORK:garage (7), eid:315940 SHM failed, re-validating it]
Jul 18 11:39:26 zoneminder zmeventnotification[631142]: ERR [Memory map file '/dev/shm/zm.mmap.7' does not exist in zmMemAttach.  zmc might not be running.]
Jul 18 11:39:28 zoneminder zmeventnotification[631142]: ERR [Memory map file '/dev/shm/zm.mmap.7' does not exist in zmMemAttach.  zmc might not be running.]
Jul 18 11:39:28 zoneminder zmeventnotification[631142]: ERR [|----> FORK:garage (7), eid:315940 SHM failed, re-validating it]
Jul 18 11:39:28 zoneminder zmeventnotification[631142]: ERR [Memory map file '/dev/shm/zm.mmap.7' does not exist in zmMemAttach.  zmc might not be running.]
Jul 18 11:39:30 zoneminder zmeventnotification[631142]: ERR [Memory map file '/dev/shm/zm.mmap.7' does not exist in zmMemAttach.  zmc might not be running.]
Jul 18 11:39:30 zoneminder zmeventnotification[631142]: ERR [|----> FORK:garage (7), eid:315940 SHM failed, re-validating it]
Jul 18 11:39:30 zoneminder zmeventnotification[631142]: ERR [Memory map file '/dev/shm/zm.mmap.7' does not exist in zmMemAttach.  zmc might not be running.]
Jul 18 11:39:32 zoneminder zmeventnotification[631142]: ERR [Memory map file '/dev/shm/zm.mmap.7' does not exist in zmMemAttach.  zmc might not be running.]
............
Jul 18 11:49:25 zoneminder zmeventnotification[631142]: ERR [Memory map file '/dev/shm/zm.mmap.7' does not exist in zmMemAttach.  zmc might not be running.]
Jul 18 11:49:25 zoneminder zmeventnotification[631142]: ERR [|----> FORK:garage (7), eid:315940 SHM failed, re-validating it]
Jul 18 11:49:25 zoneminder zmeventnotification[631142]: ERR [Memory map file '/dev/shm/zm.mmap.7' does not exist in zmMemAttach.  zmc might not be running.]
Jul 18 11:49:25 zoneminder systemd[1]: zoneminder.service: State 'stop-final-sigterm' timed out. Killing.
Jul 18 11:49:25 zoneminder systemd[1]: zoneminder.service: Killing process 631142 (zmeventnotifica) with signal SIGKILL.
Jul 18 11:49:25 zoneminder systemd[1]: zoneminder.service: Failed with result 'timeout'.
Jul 18 11:49:25 zoneminder systemd[1]: Stopped ZoneMinder CCTV recording and surveillance system.
Jul 18 11:49:25 zoneminder systemd[1]: zoneminder.service: Found left-over process 631142 (zmeventnotifica) in control group while starting unit. Ignoring.
Jul 18 11:49:25 zoneminder systemd[1]: This usually indicates unclean termination of a previous run, or service implementation deficiencies.
Jul 18 11:49:25 zoneminder systemd[1]: Starting ZoneMinder CCTV recording and surveillance system...
@baudneo
Copy link

baudneo commented Jul 19, 2022

For now you could try adding multiple comamnds in .service file

ExecReload=/usr/bin/zmdc.pl 'stop zmeventnotification.pl'; sleep 2; /usr/bin/zmpkg.pl restart

Other option is write a shell script that does the above commands but checks to see if zmeventnotification is installed/enabled first.

ExecReload=/usr/bin/my_zm_restarter.sh
@eRaid6
Copy link
Author

eRaid6 commented Jul 22, 2022

I wrote a script that I run out of cron every minute that checks for the condition and then kills zmeventnotification.pl

$ cat /usr/local/bin/kill-zmeventnotification.sh
#!/usr/bin/env bash

# zmeventnotification.pl hangs when zoneminder is trying to restart
# to work around this, we will look for the systemctl command to
# restart zoneminder, and if it exists then we will pkill the event
# notification server
# https://github.com/ZoneMinder/zmeventnotification/issues/417

if pgrep -f 'systemctl restart zoneminder'; then
	pkill -9 -f 'zmeventnotification.pl'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants