mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-21 03:39:54 +00:00
6e561ffa6d
The auto-restart path in `hermes update` verifies systemd unit health with `time.sleep(3)` + a single `systemctl is-active` call. The unit's Stopped -> Started transition after a graceful SIGUSR1 exit (or a hard restart) is not always complete inside that 3s window, so the verify races and reports 'drained but didn't relaunch' even though systemd is about to bring the unit back up a fraction of a second later. Users then see a spurious warning, a redundant fallback `systemctl restart` fires, and adapters (Discord, WhatsApp) get restarted twice. Replace the three sleep+oneshot sites with a small `_wait_for_service_active()` closure that polls `is-active` every 0.5s for up to 10s. Behaviour is unchanged when the unit is healthy or truly dead — only the race window around a clean restart is now handled correctly. Tests: tests/hermes_cli/test_update_gateway_restart.py (41/41).