systemd: KillMode=mixed for the API so main shuts its own children down

With control-group kill, SIGTERM reaches the multiprocessing Manager at
the same moment as Sanic's main process; main's cleanup then writes
worker state to a dead Manager (broken pipe) and exits 1, so a plain
`systemctl stop` is recorded as a failure whenever a child takes a
moment to stop (a transcode being killed, for instance).  Signal only
main; it stops the workers and the perpetual process itself.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Roland 2026-09-24 19:06:05 -06:00
parent 48384eb56d
commit 9e3ac4de5c
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
2 changed files with 8 additions and 0 deletions

View file

@ -15,6 +15,10 @@ Group=wrolpi
User=wrolpi
WorkingDirectory=/opt/wrolpi/
Restart=on-failure
# Signal only Sanic's main process on stop; it shuts its workers, the perpetual process and the multiprocessing
# Manager down itself. Signalling the whole cgroup at once kills the Manager under main's own cleanup (broken
# pipe, exit 1). Stragglers still get SIGKILL at TimeoutStopSec.
KillMode=mixed
# Higher than the App so the API can start.
Nice=4

View file

@ -15,6 +15,10 @@ Group=wrolpi
User=wrolpi
WorkingDirectory=/opt/wrolpi/
Restart=on-failure
# Signal only Sanic's main process on stop; it shuts its workers, the perpetual process and the multiprocessing
# Manager down itself. Signalling the whole cgroup at once kills the Manager under main's own cleanup (broken
# pipe, exit 1). Stragglers still get SIGKILL at TimeoutStopSec.
KillMode=mixed
# Higher than the App so the API can start.
Nice=4