fix(gateway): wait for systemd restart readiness#20544
Closed
helix4u wants to merge 1 commit into
Closed
Conversation
Contributor
|
Merged via #20949. Your commit was cherry-picked onto current main with your authorship preserved (d797755), plus two small follow-ups on top: narrowed the rate-limit |
Collaborator
|
Superseded by #20949 (merged), which cherry-picks this PR's changes plus follow-up improvements. |
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.
What does this PR do?
Fixes the systemd-managed gateway restart path so
hermes gateway restartdoes not report success before the replacement gateway process is actually running.The old path relied on
reload-or-restart, but the generated unit hasExecReload=/bin/kill -USR1 $MAINPID. systemd treats that as successful once the signal is delivered, even though the gateway still has to drain, exit with the planned restart code, wait through anyRestartSechandoff, and start a new runtime. That made restart output look complete while Discord/Telegram could still be unavailable.This also hardens Discord slash command reconciliation during reconnect. A restart can otherwise trigger slash-command management writes on every reconnect, and Discord's command-management bucket can rate-limit those writes for minutes. The sync now records successful command fingerprints, respects Discord retry-after signals, and spaces mutation writes instead of slamming the API.
Related Issue
N/A
Type of Change
Changes Made
hermes_cli/gateway.pyreload-or-restartpath for gateway restarts.MainPIDwhen runtime status is not yet available.systemctl restartto avoid sitting in systemd'sRestartSecauto-restart window after planned exit code 75.gateway/platforms/discord.pytests/hermes_cli/test_gateway_service.pyMainPIDfallback, immediate restart kick after graceful exit, and start-limit reporting.tests/gateway/test_discord_connect.pyHow to Test
.venv/bin/pytest tests/gateway/test_discord_connect.py tests/hermes_cli/test_gateway_service.py -n 4.venv/bin/python -m py_compile gateway/platforms/discord.py hermes_cli/gateway.pyandgit diff --checkhermes gateway restart, thenhermes gateway status, then verify a messaging-platform slash command responds after the restart message lands.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AFor New Skills
N/A
Screenshots / Logs
Targeted checks before opening the draft PR:
.venv/bin/python -m py_compile gateway/platforms/discord.py hermes_cli/gateway.py.venv/bin/pytest tests/gateway/test_discord_connect.py -k "post_connect_initialization or safe_sync" -n 4— 8 passed.venv/bin/pytest tests/gateway/test_discord_connect.py tests/hermes_cli/test_gateway_service.py -n 4— 132 passedgit diff --checkFull suite after opening the draft PR:
scripts/run_tests.sh— failed: 46 failed, 20038 passed, 51 skipped, 229 warnings in 529.48sRelated PRs checked and not duplicative: