fix(gateway): exit code 75 on service restart so launchd relaunches#28200
Closed
zccyman wants to merge 1 commit into
Closed
fix(gateway): exit code 75 on service restart so launchd relaunches#28200zccyman wants to merge 1 commit into
zccyman wants to merge 1 commit into
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 NousResearch#28135
Collaborator
outsourc-e
approved these changes
May 18, 2026
outsourc-e
left a comment
Contributor
There was a problem hiding this comment.
Reviewed locally. The touched change is narrow and matches the existing systemd restart-code convention. py_compile passed, the launchd/restart-focused status tests passed, and the broad tests/hermes_cli/test_gateway_service.py failures reproduce on main in this macOS environment, so they are baseline noise rather than introduced by this PR.
Contributor
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.
Problem
When the gateway receives
SIGUSR1(graceful restart vialaunchd_restart), the handler callsrequest_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 cleanexit(0)is treated as "successful, don't restart", so the gateway stays down after/restart,/update, orSIGUSR1.The systemd unit template already uses
RestartForceExitStatus=75for the same scenario — the launchd side has no equivalent.Closes #28135
Fix
When
_restart_via_serviceisTrue, raiseSystemExit(75)instead of returningTrue. This mirrors the systemdRestartForceExitStatus=75convention so launchd'sSuccessfulExit=falsepolicy triggers a relaunch.Files Changed
gateway/run.py— +13 lines: add exit-code-75 guard before the finalreturn TrueTesting
tests/hermes_cli/test_gateway_service.pylaunchd_restartand exit-code-75 paths already present