code wiki / (root) / nx_restart_guard.nx

nx_restart_guard.nx

buildroot/runtime/nx_restart_guard.nx

8806 B119 linesdepth 0pulls 0 transitivereach 10 importersview sourcekind librarytopic restart
docsdependenciesstructsconstsfunctions

about

nx_restart_guard.nx -- Prevents a crashing daemon from restarting indefinitely by enforcing burst limits and exponential backoff.

dependencies 0 imports · 3 importers

nx_restart_guard.nx nx_hostctl.nx nx_restart_guard_gate.nx nx_runsv.nx

imports: none

imported by: nx_hostctl.nxnx_restart_guard_gate.nxnx_runsv.nx

structs

none

consts

23const RG_DEF_INTERVAL_MS: i64 = 10000 // systemd StartLimitIntervalSec default (10s)
24const RG_DEF_BURST: i64 = 5 // systemd StartLimitBurst default
25const RG_DEF_BASE_MS: i64 = 100 // systemd RestartSec default (100ms) = our backoff base
26const RG_DEF_MAX_MS: i64 = 30000 // backoff ceiling (30s) so it never waits unboundedly
31const RG_HEALTH_RESET_MS: i64 = 60000

functions

44func rg_should_restart(ws: *i64, cnt: *i64, now: i64, cap_ms: i64, base_ms: i64) -> i64
56func rg_backoff_ms(restart_count: i64, base_ms: i64, max_ms: i64) -> i64
64func rg_remaining(cnt: i64, burst: i64) -> i64 { let r: i64 = burst - cnt; if r < 0 { return 0 } return r }
86func rg_stale_cycle(st: *i64, cyc: i64, stale_polls: i64) -> i64
called by 2: hc_guard_dsupmain
104func rg_silent_stale(st: *i64, cyc: i64, silent_polls: i64) -> i64
called by 2: hc_guard_dsupmain
113func rg_bind_grace_expired(alive: i64, socket_dead: i64, dead_polls: i64, grace_polls: i64) -> i64
called by 2: hc_guard_adminmain