code wiki / (root) / nx_runsv.nx

nx_runsv.nx

buildroot/runtime/nx_runsv.nx

5217 B96 linesdepth 7pulls 15 transitivereach 3 importersview sourcekind tooltopic runsv
docsdependenciesstructsconstsfunctions

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

nx_health_probe.nx nx_restart_guard.nx nx_svcreg.nx nx_gate.nx nx_runsv.nx nx_runsv_all.nx nx_runsv_gate.nx

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

main gw sys_write svc_get svc_get_pfx reg_get reg_key reg_cat ss_get sys_mmap ss_scan sys_mmap ↻ ss_manifest_dyn ss_scan_seglist gn sys_write ↻ sys_mmap ↻ rs_atoi rs_spawn_fg sys_fork sys_openat_wr sys_dup3 sys_execve sys_sleep_ms sys_mmap ↻ sys_munmap sys_wait4 hp_probe sys_socket sys_set_socket_timeout sys_mmap ↻ sys_setsockopt sys_munmap ↻ sys_mmap ↻ hp_sockaddr nx_connect_bounded nx_fcntl sys_connect sys_mmap ↻ sys_poll

structs

none

consts

15const RS_MAGIC_30000: i64 = 30000
16const RS_MAGIC_5000: i64 = 5000
18const RS_OK: i64 = 0
19const RS_RESPAWN: i64 = 1
20const RS_BACKOFF: i64 = 2
21const RS_KILLHUNG: i64 = 3

functions

23func 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
26func rs_spawn_fg(elf: *u8, logpath: *u8) -> i64
42func rs_decide(dead: i64, verdict: i64, ws: *i64, cnt: *i64, now: i64) -> i64
called by 3: mainmainmain calls 1: rg_should_restart
54func main(argc: i64, argv: *i64) -> i64