mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-31 06:51:29 +00:00
fix(gateway): exit code 75 on service restart so launchd relaunches
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
This commit is contained in:
parent
c5cafd3847
commit
5987b24314
1 changed files with 13 additions and 0 deletions
|
|
@ -17346,6 +17346,19 @@ async def start_gateway(config: Optional[GatewayConfig] = None, replace: bool =
|
|||
)
|
||||
return False # → sys.exit(1) in the caller
|
||||
|
||||
# When the gateway is restarting via the service manager (SIGUSR1 →
|
||||
# launchd_restart or /restart / /update commands), exit with code 75 so
|
||||
# that launchd's ``KeepAlive → SuccessfulExit → false`` policy treats
|
||||
# the exit as *unsuccessful* and relaunches the service. This mirrors
|
||||
# the systemd ``RestartForceExitStatus=75`` convention already used by
|
||||
# the systemd unit template.
|
||||
if runner._restart_via_service:
|
||||
logger.info(
|
||||
"Exiting with code 75 (service-restart requested) so "
|
||||
"launchd KeepAlive relaunches the gateway."
|
||||
)
|
||||
raise SystemExit(75)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue