fix(gateway): detect launchd via XPC_SERVICE_NAME for Telegram /restart path - #51112
Closed
verus-services wants to merge 1 commit into
Closed
fix(gateway): detect launchd via XPC_SERVICE_NAME for Telegram /restart path#51112verus-services wants to merge 1 commit into
verus-services wants to merge 1 commit into
Conversation
…rt path
The _handle_restart_command method only checked for INVOCATION_ID
(systemd) and container markers to decide whether to use the service
restart path (via_service=True, exit code 75). On macOS under launchd,
neither env var is set — but XPC_SERVICE_NAME is always present.
Without this detection, the Telegram /restart path falls through to
via_service=False (detached subprocess), which exits with code 0.
launchd's KeepAlive → SuccessfulExit → false policy treats exit(0) as
'successful, don't restart', so the gateway stays down after a
Telegram /restart command.
Add _under_launchd = bool(os.environ.get('XPC_SERVICE_NAME')) and
include it in the service-restart condition, matching the existing
systemd convention.
Refs: commit 5987b24 (original launchd fix for SIGUSR1 path)
Closes: NousResearch#28135 (Telegram /restart path was missed)
Collaborator
Contributor
|
Thanks for the focused launchd investigation. This is already implemented on current
This is an automated hermes-sweeper review. |
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.
Problem
The
_handle_restart_commandmethod only checked forINVOCATION_ID(systemd) and container markers to decide whether to use the service restart path (via_service=True, exit code 75). On macOS under launchd, neither env var is set — butXPC_SERVICE_NAMEis always present.Without this detection, the Telegram
/restartpath falls through tovia_service=False(detached subprocess), which exits with code 0. launchd'sKeepAlive → SuccessfulExit → falsepolicy treats exit(0) as 'successful, don't restart', so the gateway stays down after a Telegram/restartcommand.Fix
Add
_under_launchd = bool(os.environ.get('XPC_SERVICE_NAME'))and include it in the service-restart condition, matching the existing systemd convention.Testing
Verified on macOS 25.3 (arm64):
XPC_SERVICE_NAME=ai.hermes.gateway-danteis set when running under launchd. The fix ensures the Telegram/restartpath usesvia_service=Trueand exits with code 75, which launchd'sSuccessfulExit → falsepolicy correctly treats as a restart trigger.References
/restartpath was missed)