nx_runsv.nx
buildroot/runtime/nx_runsv.nx
about
nx_runsv.nx -- RUN + SUPERVISE one service (s6/runit `runsv` convention). This is the REAL fork/wait-liveness +
real-health + backoff supervisor that the existing nx_supervise gate (runtime/_hdl_build/nx_supervise.nx) explicitly
flags as "remaining" (its health is MODELED; this wires it to reality). Best-practice model (June-2026: supervisord/
s6/runit/systemd): the SUPERVISOR daemonizes, the SERVICE runs FOREGROUND under it. Composes the team's organs --
NO hand-rolled daemonize/health/backoff:
nx_health_probe.hp_probe -> readiness (serving, not just bound; catches HUNG)
nx_restart_guard.rg_should_restart -> crash-loop backoff (systemd-parity + exponential)
fork + fd->log + execve + wait4(WNOHANG) -> foreground spawn + liveness
Roadmap: knowledge/research/2026-06-30-service-supervisor-roadmap.md. Usage: nx_runsv <elf-path> <port>
license_tier: ORIGINAL
dependencies 4 imports · 2 importers
imports: nx_health_probe.nxnx_restart_guard.nxnx_svcreg.nxnx_gate.nx
imported by: nx_runsv_all.nxnx_runsv_gate.nx
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 15 | const RS_MAGIC_30000: i64 = 30000 |
| 16 | const RS_MAGIC_5000: i64 = 5000 |
| 18 | const RS_OK: i64 = 0 |
| 19 | const RS_RESPAWN: i64 = 1 |
| 20 | const RS_BACKOFF: i64 = 2 |
| 21 | const RS_KILLHUNG: i64 = 3 |
functions
| 23 | func rs_atoi(s: *u8) -> i64 { var v: i64=0; var i: i64=0; while s[i]!=(0 as u8){ let d: i64=s[i] as i64; if d>=48 { if d<=57 { v=v*10+(d-48) } } i=i+1 } return v } called by 1: main |
| 26 | func rs_spawn_fg(elf: *u8, logpath: *u8) -> i64 |
| 42 | func rs_decide(dead: i64, verdict: i64, ws: *i64, cnt: *i64, now: i64) -> i64 |
| 54 | func main(argc: i64, argv: *i64) -> i64 |