fix: prevent systemd restart storm on gateway connection failure

Cherry-picked from PR #2319 by @itenev.

When the gateway fails to connect (e.g. PrivilegedIntentsRequired,
missing token), systemd's default RestartSec=10 with no start rate
limit causes rapid reconnect storms flooding logs and triggering
platform-side rate limits.

- StartLimitIntervalSec=600 + StartLimitBurst=5 in [Unit] (max 5
  restarts per 10 min)
- RestartSec: 10 → 30
- Applied to both templates in gateway.py and scripts/hermes-gateway
This commit is contained in:
Teknium
2026-03-21 09:26:39 -07:00
parent 3ba6043c62
commit 326b146d68
2 changed files with 9 additions and 3 deletions

View File

@@ -82,13 +82,15 @@ def generate_systemd_unit() -> str:
return f"""[Unit]
Description={SERVICE_DESCRIPTION}
After=network.target
StartLimitIntervalSec=600
StartLimitBurst=5
[Service]
Type=simple
ExecStart={python_path} {script_path} run
WorkingDirectory={working_dir}
Restart=on-failure
RestartSec=10
RestartSec=30
StandardOutput=journal
StandardError=journal