fix(gateway): detect stopped processes and release stale locks on --replace

This commit is contained in:
Teknium 2026-03-21 18:13:53 -07:00
parent 29d0541ac9
commit 4bded44b6a
No known key found for this signature in database
2 changed files with 44 additions and 0 deletions

View file

@ -5173,6 +5173,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(