Skip to content

fix(gateway): use unconditional KeepAlive in launchd plist so gateway restarts after clean --replace exit (#37388) - #37411

Closed
Tranquil-Flow wants to merge 1 commit into
NousResearch:mainfrom
Tranquil-Flow:fix/37388-launchd-keepalive
Closed

fix(gateway): use unconditional KeepAlive in launchd plist so gateway restarts after clean --replace exit (#37388)#37411
Tranquil-Flow wants to merge 1 commit into
NousResearch:mainfrom
Tranquil-Flow:fix/37388-launchd-keepalive

Conversation

@Tranquil-Flow

Copy link
Copy Markdown
Contributor

What does this PR do?

Changes the launchd plist from KeepAlive.SuccessfulExit=false to unconditional <key>KeepAlive</key><true/> so launchd restarts the gateway on ALL exit codes — including clean exit (0) from --replace. Previously, a clean --replace exit left the gateway down indefinitely.

Also updates the stale _graceful_restart_via_sigusr1 docstring that documented the old SuccessfulExit=false behavior.

Related Issue

Fixes #37388

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • tests/hermes_cli/test_gateway_service.py — 130 passed (6 pre-existing systemd env failures unrelated)
  • Fail-without-fix verified by reviewer
  • Reviewer improvement pass applied — updated docstring, expanded test assertions

Root Cause

generate_launchd_plist() used KeepAlive.SuccessfulExit=false. When --replace triggered a clean exit (code 0), launchd did NOT restart — gateway stayed down.

Fix

Change to unconditional <key>KeepAlive</key><true/> — launchd always restarts regardless of exit code, matching systemd Restart=always.

Checklist

  • My code follows the code style of this project
  • I have added tests that prove my fix is effective
  • All new and existing tests pass locally
  • No new dependencies added
  • No AI attribution in commits

… restarts after clean --replace exit (NousResearch#37388)

The launchd plist used KeepAlive.SuccessfulExit=false, meaning launchd
only restarted the gateway on non-zero exits.  When --replace caused a
clean exit (code 0), the gateway stayed down indefinitely.

Change to unconditional <key>KeepAlive</key><true/> so launchd always
restarts the gateway regardless of exit code — matching systemd's
Restart=always behavior.

Also updates the stale _graceful_restart_via_sigusr1 docstring that
documented the old SuccessfulExit=false behavior.
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery labels Jun 2, 2026
@teknium1

teknium1 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Fixed via PR #39000 (#39000), merged to main. You submitted the first fix for this issue and identified the correct approach — credited in the merged PR. The salvaged implementation (#38796) was selected for its test + comment polish, but your diagnosis was spot on. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: gateway launchd KeepAlive (SuccessfulExit:false) doesn't restart after a clean --replace exit on macOS

3 participants