mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-18 04:41:56 +00:00
fix(gateway): refresh runtime argv metadata
This commit is contained in:
parent
7d276bfbee
commit
124fbb0af0
2 changed files with 29 additions and 3 deletions
|
|
@ -482,10 +482,12 @@ def write_runtime_status(
|
|||
"""Persist gateway runtime health information for diagnostics/status."""
|
||||
path = _get_runtime_status_path()
|
||||
payload = _read_json_file(path) or _build_runtime_status_record()
|
||||
current_record = _build_pid_record()
|
||||
payload.setdefault("platforms", {})
|
||||
payload.setdefault("kind", _GATEWAY_KIND)
|
||||
payload["pid"] = os.getpid()
|
||||
payload["start_time"] = _get_process_start_time(os.getpid())
|
||||
payload["kind"] = current_record["kind"]
|
||||
payload["pid"] = current_record["pid"]
|
||||
payload["argv"] = current_record["argv"]
|
||||
payload["start_time"] = current_record["start_time"]
|
||||
payload["updated_at"] = _utc_now_iso()
|
||||
|
||||
if gateway_state is not _UNSET:
|
||||
|
|
|
|||
|
|
@ -287,6 +287,30 @@ class TestGatewayRuntimeStatus:
|
|||
assert payload["pid"] == os.getpid(), "PID should be overwritten, not preserved via setdefault"
|
||||
assert payload["start_time"] != 1000.0, "start_time should be overwritten on restart"
|
||||
|
||||
def test_write_runtime_status_overwrites_stale_argv_on_restart(self, tmp_path, monkeypatch):
|
||||
"""Regression: gateway_state.json must not keep the previous launch argv."""
|
||||
monkeypatch.setenv("HERMES_HOME", str(tmp_path))
|
||||
|
||||
state_path = tmp_path / "gateway_state.json"
|
||||
state_path.write_text(json.dumps({
|
||||
"pid": 99999,
|
||||
"start_time": 1000.0,
|
||||
"kind": "hermes-gateway",
|
||||
"argv": ["/old/path/hermes", "gateway", "run"],
|
||||
"platforms": {},
|
||||
"updated_at": "2025-01-01T00:00:00Z",
|
||||
}))
|
||||
|
||||
monkeypatch.setattr(status.sys, "argv", ["/new/path/hermes", "gateway", "run"])
|
||||
monkeypatch.setattr(status, "_get_process_start_time", lambda pid: 2000)
|
||||
|
||||
status.write_runtime_status(gateway_state="running")
|
||||
|
||||
payload = status.read_runtime_status()
|
||||
assert payload["argv"] == ["/new/path/hermes", "gateway", "run"]
|
||||
assert payload["pid"] == os.getpid()
|
||||
assert payload["start_time"] == 2000
|
||||
|
||||
def test_write_runtime_status_records_platform_failure(self, tmp_path, monkeypatch):
|
||||
monkeypatch.setenv("HERMES_HOME", str(tmp_path))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue