majestic: make S95majestic stop work when the pidfile is stale - #2245
majestic: make S95majestic stop work when the pidfile is stale#2245phedoreanu wants to merge 2 commits into
Conversation
majestic's built-in watchdog respawns the process outside start-stop-daemon's knowledge, so /var/run/majestic.pid goes stale. 'stop' then kills nothing (start-stop-daemon -K targets the dead pid), and 'restart' starts a second majestic next to the surviving one - two daemons fight over the encoder and config edits appear to take effect but the running process never loaded them. Observed on a Hi3518EV200 camera: pidfile said 3408, majestic ran as 869, /etc/init.d/S95majestic restart exited 0 having restarted nothing; /api/v1/config.json confirmed the old config was still live. After the pidfile kill, verify the daemon is gone with pidof and fall back to killall (TERM, then KILL), which matches by name and cannot go stale. Always remove the pidfile so the next start begins clean.
PR Summary by QodoFix S95majestic stop/restart when /var/run/majestic.pid is stale
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
Code Review by Qodo
1.
|
Review follow-up: verify the daemon is actually gone after the kill sequence. If it survives even SIGKILL, print FAIL and return non-zero, and make restart abort instead of starting a second instance next to a daemon that refused to die. The pidfile is only removed once the daemon is confirmed gone.
majestic's built-in watchdog respawns the process outside start-stop-daemon's knowledge, so
/var/run/majestic.pidgoes stale.stopthen kills nothing (start-stop-daemon -Ktargets the dead pid), andrestartstarts a second majestic next to the surviving one — two daemons fight over the encoder, and config edits appear to take effect while the running process never loaded them.Observed on a Hi3518EV200 camera: the pidfile said 3408, majestic ran as pid 869;
/etc/init.d/S95majestic restartexited 0 having restarted nothing, and/api/v1/config.jsonconfirmed the old config was still live.After the pidfile kill, this verifies the daemon is actually gone with
pidofand falls back tokillall(TERM, then KILL) — matching by name, the one identity that cannot go stale. The pidfile is always removed so the next start begins clean.