Skip to content

fix(launchd): use unconditional KeepAlive so gateway restarts after clean exit #37388 - #37534

Closed
kyssta-exe wants to merge 1 commit into
NousResearch:mainfrom
kyssta-exe:auto-fix/issue-37388-v2
Closed

fix(launchd): use unconditional KeepAlive so gateway restarts after clean exit #37388#37534
kyssta-exe wants to merge 1 commit into
NousResearch:mainfrom
kyssta-exe:auto-fix/issue-37388-v2

Conversation

@kyssta-exe

Copy link
Copy Markdown
Contributor

Summary

The launchd plist shipped with KeepAlive.SuccessfulExit=false, which meant launchd only restarted the gateway on non-zero exit. When gateway run --replace triggered a clean exit (code 0), launchd did not relaunch it, leaving the gateway down indefinitely until manually restarted.

Fix

Changed KeepAlive from:

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

To:

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

This ensures the gateway always restarts regardless of exit code, which is the correct behavior for a long-lived service managed by launchd.

Testing

  • All 13 existing launchd-related tests pass
  • Verified the generated plist output contains unconditional <true/> KeepAlive
  • No functional changes to gateway restart logic on other platforms

Fixes #37388

…lean exit

The launchd plist shipped with KeepAlive.SuccessfulExit=false, which
meant launchd only restarted the gateway on non-zero exit. When
'gateway run --replace' triggered a clean exit (code 0), launchd did
not relaunch it, leaving the gateway down indefinitely until manually
restarted.

Changed KeepAlive to unconditional true so the gateway always restarts
regardless of exit code. Also updated docstrings to reflect the new
KeepAlive policy.

Fixes NousResearch#37388
@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists duplicate This issue or pull request already exists labels Jun 2, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #37411 — both make the launchd plist KeepAlive unconditional (<true/>) so the gateway restarts after a clean gateway run --replace exit. Same root cause as #9659 / #37388, and same fix proposed in #9689 / #14001. Consolidating on one PR would help.

@teknium1

teknium1 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Fixed via PR #39000 (#39000), merged to main. Same fix as yours — the salvaged implementation (#38796) shipped with the launchd test. Credited as a duplicate contributor. Thanks!

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

Labels

comp/gateway Gateway runner, session dispatch, delivery duplicate This issue or pull request already exists 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