Merge pull request #2406 from NousResearch/hermes/hermes-31d7db3b

fix(gateway): detect stopped processes and release stale locks on --replace
This commit is contained in:
Teknium 2026-03-21 18:16:15 -07:00 committed by GitHub
commit dd39003a9b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 44 additions and 0 deletions

View file

@ -5408,6 +5408,16 @@ async def start_gateway(config: Optional[GatewayConfig] = None, replace: bool =
except (ProcessLookupError, PermissionError):
pass
remove_pid_file()
# Also release all scoped locks left by the old process.
# Stopped (Ctrl+Z) processes don't release locks on exit,
# leaving stale lock files that block the new gateway from starting.
try:
from gateway.status import release_all_scoped_locks
_released = release_all_scoped_locks()
if _released:
logger.info("Released %d stale scoped lock(s) from old gateway.", _released)
except Exception:
pass
else:
hermes_home = os.getenv("HERMES_HOME", "~/.hermes")
logger.error(