fix(gateway): drop --replace + Restart=on-failure in generated service units - #35102
fix(gateway): drop --replace + Restart=on-failure in generated service units#35102teknium1 wants to merge 1 commit into
Conversation
|
@benbarclay — pulling you in on the container-mode change since you own the Docker/OCI lifecycle. Question I wanted to verify before dropping Conclusion: no. Walking the lifecycle:
The only scenario where
Either path → new gateway starts clean without So removing it is a no-op in the happy path and removes a foot-gun in the SIGKILL-recovery path. Flagging in case you have a container restart edge case I'm not seeing (e.g. a non-host-PID-namespace backend, or a setup where the PID file isn't on the mounted volume). If so, shout and I'll keep it for the container path only. |
🔎 Lint report:
|
8825ad2 to
31ba091
Compare
…e units Under a process supervisor (systemd/launchd), --replace makes each supervised restart kill its predecessor, producing self-kill loops, and Restart=always revives even clean manual stops. Generated units now run plain 'gateway run' with Restart=on-failure (+RestartForceExitStatus=75 for drain-restarts); the Nix module default follows suit. --replace stays on the manual/detached fallback paths where no supervisor owns the lifecycle.
31ba091 to
0fc14fc
Compare
Summary
Hermes-generated gateway service units no longer launch with
--replaceor revive clean exits — the systemd restart loop in the bug report is gone.Salvages #23281 and #32989 (both @LeonSGP43) and extends the same fix to the NixOS module.
Changes
hermes_cli/gateway.py: drop--replacefrom both systemd unit templates, the launchd plist, and_gateway_run_args_for_profile; flipRestart=always→Restart=on-failure(fix(gateway): stop default replace in service runs #23281 + fix(gateway): avoid systemd restart loops on replace #32989).nix/nixosModules.nix: defaultRestartalways→on-failurefor the host unit; drop--replacefrom the container-mode (OCI)container createcommand.--replaceabsent +Restart=on-failurepresent across user/system units, launchd plist, and run-args.Why it's safe
The non-
--replacestart path returns "already running" only whenget_running_pid()finds a live gateway — that function checks runtime-lock-active +_pid_exists+ start-time match + gateway-process shape, and cleans up stale PID files otherwise (gateway/status.py:1011-1035). After systemd SIGTERMs the old process, the new one seesNoneand starts clean. The graceful-restart path is untouched: SIGUSR1 → exit 75 →RestartForceExitStatus=75still respawns.--replaceremains available as a manual CLI flag for interactive takeover.Validation
tests/hermes_cli/test_gateway_service.py--replace,Restart=on-failure, exit-75 preservedCloses #23281, #32989. Original bug report cc'd. Contributor authorship preserved via rebase-merge.