From 9e3ac4de5c871b419038d82e9d20fdc64d44dd83 Mon Sep 17 00:00:00 2001 From: Roland Date: Thu, 24 Sep 2026 19:06:05 -0600 Subject: [PATCH] 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 --- etc/raspberrypios/wrolpi-api-dev.service | 4 ++++ etc/raspberrypios/wrolpi-api.service | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/etc/raspberrypios/wrolpi-api-dev.service b/etc/raspberrypios/wrolpi-api-dev.service index 4e8de8ff..2f4c8fae 100644 --- a/etc/raspberrypios/wrolpi-api-dev.service +++ b/etc/raspberrypios/wrolpi-api-dev.service @@ -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 diff --git a/etc/raspberrypios/wrolpi-api.service b/etc/raspberrypios/wrolpi-api.service index dbc5e015..724e606f 100644 --- a/etc/raspberrypios/wrolpi-api.service +++ b/etc/raspberrypios/wrolpi-api.service @@ -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