nx_torrent_keep.nx
buildroot/runtime/nx_torrent_keep.nx
about
nx_torrent_keep.nx -- SOVEREIGN local keeper for the /torrent media daemon (:8097).
Mirrors the NAS-side nx_hostctl reader-keeper: it ENSURES the daemon is up by delegating to the
idempotent nx_torrent_up (so the build/launch logic is NOT duplicated -- DRY #15), then SUPERVISES it --
polling liveness and, on death, respawning with an ESCALATING crash-loop backoff. never-brick #26 /
graceful-degradation #14: a persistently-broken daemon backs off to a capped 30s retry, NEVER a tight
respawn loop. Runs FOREVER; it is ignited at Windows logon (the user Startup .vbs) and kept resident by
the locked-in vmIdleTimeout, so the LOCAL daemon gets the same death-respawn supervision the NAS fleet
already has under nx_hostctl. Takes NO args, so the WOMB runs it directly: `nx_sov_build_run.elf
nx_torrent_keep` (no --build-only/persisted-elf dance needed).
license_tier: ORIGINAL layer: L7 (local supervisor over the L6 daemon)
module: nishi-core.torrent.keep
depends: nishi-core.syscalls
dependencies 1 imports · 0 importers
imports: nx_syscalls.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 17 | const KEEP_HEALTHY_MS: i64 = 10000 // a daemon that ran >= this before dying is "healthy" -> reset fails |
| 18 | const KEEP_POLL_MS: i64 = 5000 // liveness poll cadence |
| 19 | const KEEP_BACKOFF_STEP_MS: i64 = 2000 // backoff grows by this per consecutive fast death |
| 20 | const KEEP_BACKOFF_MAX_MS: i64 = 30000 // ...capped here (never a tight loop) |
functions
| 22 | func k_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } |
| 23 | func k_putn(v: i64) -> i64 |
| 31 | func k_read_pid(path: *u8) -> i64 |
| 40 | func k_alive(pid: i64) -> i64 { if pid <= 0 { return 0 } if nx_kill(pid, 0) == 0 { return 1 } return 0 } |
| 45 | func k_ensure_up(envp: *i64) -> i64 |
| 58 | func main() -> i64 |