Repository navigation
majestic: start it again after a crash, and stop after five in ten minutes - #2558
Conversation
…nutes Nothing restarted majestic when it died: a camera that crashed once was without video until someone restarted it or power-cycled it. S95majestic now runs it under a small supervisor (this script, `supervise`) which starts it again when it dies of a fault -- SIGSEGV, SIGBUS, SIGILL, SIGFPE, SIGABRT, or SIGKILL from the out-of-memory killer -- after 5 s, then 30 s, then 2 min. After five crashes in ten minutes it stops trying and leaves /etc/crash/majestic.loop (when, how many, which signal), which the web interface reports, so a majestic that dies at every start does not hold the camera in a restart loop. A majestic stopped on purpose (SIGTERM, SIGINT) or exiting by itself is not started again, nor one that crashes while sysupgrade holds its lock: the upgrade brings majestic back itself. stop ends the supervisor first, also while it waits, so nothing starts majestic behind it. A start clears the loop note. The daemon is still found by executable, keeps argv[0], -s and the SIGHUP ignore, and pidof majestic is unchanged. .github/scripts/test_majestic_supervise.sh runs the script against a stub majestic and start-stop-daemon, in the shipped and the stripped form.
PR Summary by QodoRestart majestic after crashes with bounded retries
AI Description
Diagram
High-Level Assessment
Files changed (3)
|
Code Review by Qodo
1.
|
- start and stop take a lock holding the holder's pid, taken over only from a holder that is gone; start returns once the supervisor it launched is the process the pid file names, so two starts at once leave one supervisor and a stop right after a start finds it. - The supervisor asks for the upgrade lock before every start, so an upgrade that begins while it waits after a crash is not started over. - The supervisor is recognised by its last two arguments, this script and `supervise`, not by any command line that contains the word. - ci-matrix classifies the new test as no-build.
|
Addressed Qodo's review in b5d2321:
Also classified the new test in |
Symptom
Nothing restarts majestic when it dies. On every board, one crash leaves the camera without video until someone restarts majestic or power-cycles the camera.
Change
S95majesticnow runs majestic under a small supervisor: the same script, called withsupervise./etc/crash/majestic.loop(utc=,crashes=,signal=). The web interface reports it (crashlog: majestic's own crashes, on the page and sent with their build majestic-webui#648)./tmp/sysupgrade.lockexists, since the upgrade brings majestic back itself (and sysupgrade's SIGQUIT doesn't end majestic anyway).stop: ends the supervisor first, including while it is waiting to restart, so nothing starts majestic behind the stopper. The supervisor's pid is checked against its command line before it is signalled.start: clears the loop note, since it describes a run that is over.-x), keepsargv[0],-sand the inherited SIGHUP ignore.pidof majesticand S99bootok's health check see the same process as before. A majestic that keeps crashing at boot still fails bootok's window and escalates to failsafe, as before.When majestic dies it now also leaves a crash dump in
/etc/crash, which the WebUI can send (OpenIPC/website#415, OpenIPC/majestic-webui#648). The restart doesn't touch it.Hardware evidence
gk7205v300 + imx335 (
master+988f385, 2026-10-05), with thisS95majesticinstalled in place of the shipped one and afterwards restored:stopduring its wait:kill -3 majestic(what sysupgrade sends) left the same pid running.restart: brought both back (majestic=8226 supervisor=8224).T31 + sc2332 (
master+3f53bec, 2026-09-26; MIPS, where SIGBUS is 10):Both cameras were put back on their own
S95majesticafterwards.Tests
.github/scripts/test_majestic_supervise.shruns the real script against a stub majestic and a stubstart-stop-daemon, in both the shipped and the comment-stripped form. It checks:It is wired into
shell-tests.ymland passes locally.