Repository navigation
fix(gateway): track + reap no-systemd gateway restart runtimes (WSL orphan) - #51678
Merged
Merged
Conversation
🔎 Lint report:
|
Builds on @wgu9's runtime-tracking fix: now that find_gateway_pids() can see a no-supervisor `gateway restart` runtime, have stop_profile_gateway() fall back to an orphan-aware, profile-scoped reap (SIGTERM then SIGKILL) when the pidfile/runtime record is missing or stale. Closes the duplicate- accumulation path in #51325 — a follow-up restart now kills the prior orphan instead of stacking another listener on :8644. Gated on not supports_systemd_services() so a transient `gateway restart` argv on supervised hosts is never killed. Also adds the AUTHOR_MAP entry for the salvaged contributor.
teknium1
force-pushed
the
hermes/hermes-ee064db6
branch
from
June 24, 2026 05:00
aeda22e to
47c3166
Compare
13 of 19 tasks
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
On WSL/no-systemd hosts, a tracked gateway now survives
gateway restart//restart/ dashboard /hermes updatewithout leaving an orphaned, untracked listener on:8644— status reports it accurately,stopcan see it, and a follow-up restart reaps the prior instance instead of stacking duplicates.Root cause (#51325): With no service supervisor,
hermes gateway restartfalls torun_gateway()in the same process (hermes_cli/gateway.pyrestart branch), so the live gateway's argv stays… gateway restart. The strictlooks_like_gateway_command_line()matcher only acceptsgateway run, so process scans and the runtime-record validator both reject the live gateway →statussays "stopped",stop --allcan't find it, restarts can't reap the prior orphan → duplicates pile up on the port.Changes
gateway/status.py(@wgu9): addlooks_like_gateway_runtime_command_line()acceptingrestart; use it for runtime-record validation;get_running_pid()falls back to a validated livegateway_state.jsonPID when no pidfile path is given. Strict matcher unchanged for everything else.hermes_cli/gateway.py(@wgu9):_scan_gateway_pids(include_restart_managers=…);find_gateway_pids()enables it only whennot supports_systemd_services(), so supervised hosts never false-match a transientgateway restart.hermes_cli/gateway.py(follow-up):stop_profile_gateway()now falls back to_reap_unsupervised_gateway_orphans()when the pidfile/runtime record yields nothing — a profile-scoped, no-systemd-gated SIGTERM→SIGKILL of the orphan, closing the duplicate-accumulation path (suggested fix Architecture planning #3 in the issue). SIGKILL mirrors the field report where SIGTERM released the port but the process kept running.Validation
statuson no-systemd restart runtimestop/ scan sees orphan:8644tests/hermes_cli/test_gateway.py tests/gateway/test_gateway_command_line_matcher.py tests/gateway/test_status.py tests/hermes_cli/test_gateway_proc_fallback.py→ 159 passed./procentry + real process, tempHERMES_HOME): strict matcher rejectsgateway restart, runtime matcher accepts;find_gateway_pids(all_profiles=True)finds the live orphan; reaper SIGTERM/SIGKILLs it; foreign---profileprocess is correctly excluded from the profile-scoped reap.Salvage of #51468 by @wgu9 (cherry-picked, authorship preserved) + follow-up reap.
Fixes #51325. Closes #51468.
Infographic