code wiki / (root) / nx_torrent_keep.nx

nx_torrent_keep.nx

buildroot/runtime/nx_torrent_keep.nx

4664 B77 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tooltopic torrent
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_torrent_keep.nx

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

main sys_mmap k_puts sys_write k_ensure_up sys_fork sys_openat_wr sys_dup3 sys_mmap ↻ sys_execve sys_exit sys_wait4 k_read_pid sys_openat_rd sys_mmap ↻ sys_read sys_close sys_now_ms sys_mmap ↻ sys_clock_gettime_mono k_alive nx_kill k_putn sys_mmap ↻ sys_write ↻ sys_sleep_ms sys_mmap ↻ sys_munmap

structs

none

consts

17const KEEP_HEALTHY_MS: i64 = 10000 // a daemon that ran >= this before dying is "healthy" -> reset fails
18const KEEP_POLL_MS: i64 = 5000 // liveness poll cadence
19const KEEP_BACKOFF_STEP_MS: i64 = 2000 // backoff grows by this per consecutive fast death
20const KEEP_BACKOFF_MAX_MS: i64 = 30000 // ...capped here (never a tight loop)

functions

22func 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 }
called by 1: main calls 1: sys_write
23func k_putn(v: i64) -> i64
called by 1: main calls 2: sys_mmapsys_write
31func k_read_pid(path: *u8) -> i64
40func k_alive(pid: i64) -> i64 { if pid <= 0 { return 0 } if nx_kill(pid, 0) == 0 { return 1 } return 0 }
called by 1: main calls 1: nx_kill
45func k_ensure_up(envp: *i64) -> i64
58func main() -> i64