fix(gateway): use unconditional KeepAlive in launchd plist - #10637
Closed
IISweetHeartII wants to merge 1 commit into
Closed
fix(gateway): use unconditional KeepAlive in launchd plist#10637IISweetHeartII wants to merge 1 commit into
IISweetHeartII wants to merge 1 commit into
Conversation
The generated launchd plist uses `KeepAlive.SuccessfulExit = false`, which only restarts the gateway on non-zero exit. When the gateway exits cleanly (code 0) — e.g., after a transient Discord command sync failure or a graceful shutdown triggered by `--replace` — launchd does not restart it, leaving cron jobs unable to fire. Changed to unconditional `KeepAlive: true` so the gateway always restarts regardless of exit code. This matches the behavior users expect from a daemon managed by launchd. Added `ThrottleInterval: 5` to prevent overly aggressive restart loops while still recovering quickly from crashes. Intentional stops are unaffected: `launchd_stop()` already uses `launchctl bootout` which fully unloads the service definition, preventing KeepAlive from respawning the process. Refs: #9659
Contributor
|
Thanks for the contribution, @IISweetHeartII! Closing this as a duplicate of #9689 (by @digging-airfare-4u), which targets the same fix/feature. We're consolidating on that PR for review. If you want to help push it over the line, please jump in there — or if you think your approach is better for a specific reason that isn't covered in the other PR, let us know and we can reopen. |
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.
Summary
The generated launchd plist uses
KeepAlive > SuccessfulExit = false, which means the gateway is not restarted when it exits with code 0 (clean exit). This causes the gateway to silently die and never recover in several real-world scenarios:--replacelogic detects stale processes → exits cleanly → launchd doesn't restartBefore
Gateway exits with code 0 → stays dead. Cron jobs stop firing. No recovery until manual restart.
After
Gateway always restarts regardless of exit code.
ThrottleInterval: 5prevents overly aggressive restart loops.Why this is safe
launchd_stop()already useslaunchctl bootoutwhich fully unloads the service definition, preventing KeepAlive from respawning. So intentional stops (viahermes gateway stoporhermes update) are completely unaffected.Test plan
hermes gateway stop/hermes updatestill cleanly stop the gatewayhermes cron statusreports gateway as running after restartFixes #9659