fix(gateway): exit code 75 on service restart so launchd relaunches (#28200)#28341
Merged
Conversation
When the gateway receives SIGUSR1 (graceful restart via launchd_restart), the SIGUSR1 handler calls request_restart(via_service=True) and the gateway shuts down cleanly with exit code 0. However, the generated launchd plist uses KeepAlive → SuccessfulExit → false, meaning launchd only relaunches on *non-zero* exit codes. A clean exit(0) is treated as "successful, don't restart", so the gateway stays down after /restart, /update, or SIGUSR1. The systemd unit template already uses RestartForceExitStatus=75 for the same scenario. Mirror that convention: when _restart_via_service is True, raise SystemExit(75) so launchd's SuccessfulExit=false policy triggers a relaunch. Closes #28135
Contributor
🔎 Lint report:
|
This was referenced May 23, 2026
This was referenced May 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Salvage of #28200 by @zccyman.
What: When the gateway restarts via the service manager (SIGUSR1
launchd_restartor/restart//updatecommands), it was exiting 0 — which launchd'sKeepAlive → SuccessfulExit → falsepolicy treats as a clean shutdown that should NOT be relaunched. The user-initiated restart therefore left the gateway dead.How: Raise
SystemExit(75)when_restart_via_serviceis set, mirroring the systemdRestartForceExitStatus=75convention already used in the systemd unit template. launchd sees the non-zero exit and relaunches.Original PR: #28200
Fixes #28135.