nx_restart_guard.nx
buildroot/runtime/nx_restart_guard.nx
about
nx_restart_guard.nx -- Prevents a crashing daemon from restarting indefinitely by enforcing burst limits and exponential backoff.
dependencies 0 imports · 3 importers
imports: none
imported by: nx_hostctl.nxnx_restart_guard_gate.nxnx_runsv.nx
structs
| none |
consts
| 23 | const RG_DEF_INTERVAL_MS: i64 = 10000 // systemd StartLimitIntervalSec default (10s) |
| 24 | const RG_DEF_BURST: i64 = 5 // systemd StartLimitBurst default |
| 25 | const RG_DEF_BASE_MS: i64 = 100 // systemd RestartSec default (100ms) = our backoff base |
| 26 | const RG_DEF_MAX_MS: i64 = 30000 // backoff ceiling (30s) so it never waits unboundedly |
| 31 | const RG_HEALTH_RESET_MS: i64 = 60000 |
functions
| 44 | func rg_should_restart(ws: *i64, cnt: *i64, now: i64, cap_ms: i64, base_ms: i64) -> i64 called by 37: hc_guard_onehc_guard_readerhc_guard_galx_servehc_guard_arcsrvhc_guard_galx_gwhc_guard_wiki_gw+31 calls 1: rg_backoff_ms |
| 56 | func rg_backoff_ms(restart_count: i64, base_ms: i64, max_ms: i64) -> i64 |
| 64 | func rg_remaining(cnt: i64, burst: i64) -> i64 { let r: i64 = burst - cnt; if r < 0 { return 0 } return r } |
| 86 | func rg_stale_cycle(st: *i64, cyc: i64, stale_polls: i64) -> i64 |
| 104 | func rg_silent_stale(st: *i64, cyc: i64, silent_polls: i64) -> i64 |
| 113 | func rg_bind_grace_expired(alive: i64, socket_dead: i64, dead_polls: i64, grace_polls: i64) -> i64 |