Skip to content

fix(gateway): keep launchd KeepAlive unconditional for macOS resilience - #35668

Closed
drzeast-png wants to merge 2 commits into
NousResearch:mainfrom
drzeast-png:fix/gateway-keepalive-unconditional
Closed

fix(gateway): keep launchd KeepAlive unconditional for macOS resilience#35668
drzeast-png wants to merge 2 commits into
NousResearch:mainfrom
drzeast-png:fix/gateway-keepalive-unconditional

Conversation

@drzeast-png

Copy link
Copy Markdown

Problem

On macOS, when the gateway exits cleanly (e.g. during hermes gateway stop or a controlled restart), the current KeepAlive policy {SuccessfulExit: false} does NOT restart it — launchd treats exit code 0 as "intentional" and leaves the service dead.

Change

Replace:

<key>KeepAlive</key>
<dict>
    <key>SuccessfulExit</key>
    <false/>
</dict>

With:

<key>KeepAlive</key>
<true/>

This ensures launchd always restarts the gateway after any exit, matching the expectation that the service runs continuously.

Verification

Tested on macOS 26.5: after applying this change, hermes gateway stop properly unloads via bootout (which removes the service definition), while a crash or SIGTERM without bootout correctly respawns the process.

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery comp/cli CLI entry point, hermes_cli/, setup wizard labels May 31, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #14001 and #9689 (both open) — same fix: unconditional KeepAlive in launchd plist. Also previously submitted as #29111 (closed). Root issue: #9659.

Consider closing in favor of whichever of #14001 or #9689 is rebased first.

@drzeast-png

Copy link
Copy Markdown
Author

🔔 Bumping — this PR is still relevant and ready for review.

Recent context:

Behavior after all three merge:

  • launchd KeepAlive unconditional (this PR) → respawn on any exit
  • via_service=True on macOS → clean exit, launchd restarts natively, no detached watcher race
  • _HERMES_GATEWAY guard dropped → manual restart from WeChat/Telegram works

Happy to address review feedback or split into smaller PRs if preferred.

@drzeast-png
drzeast-png force-pushed the fix/gateway-keepalive-unconditional branch from b4a90ca to 52be890 Compare June 4, 2026 03:33
张东 added 2 commits June 4, 2026 12:20
…estarts

Allow restart/stop from inside the gateway (e.g. via WeChat/Telegram)
so the user can manage the gateway remotely. Trust launchd KeepAlive
as the only respawn policy; the upstream blanket guard (NousResearch#35679) blocks
legitimate manual restarts. Supersedes the still-open PR NousResearch#35815
(loop-detector variant).
…resilience

Changes KeepAlive from {SuccessfulExit: false} to unconditional <true/>
so launchd restarts the gateway process on every exit, not just abnormal
exits.  This prevents edge cases where a clean shutdown (exit code 0)
leaves the gateway dead until manually restarted.
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.

2 participants