code wiki / _hdl_build / nx_gallery_gw_guard.nx

nx_gallery_gw_guard.nx

buildroot/runtime/_hdl_build/nx_gallery_gw_guard.nx

7249 B139 linesdepth 5pulls 6 transitivereach 0 importersview sourcekind tooltopic gallery
docsdependenciesstructsconstsfunctions

about

nx_gallery_gw_guard.nx -- SOVEREIGN crash-revive supervisor for the LIVE gallery stack (backend serve :18090 + opaque gateway :18190). BOTH currently run root/ORPHANED (PPID 1) with NO supervisor: a crash = permanent outage of the gallery AND the /gallery/curator surface until a human relaunches by hand. This guard, dispatched ARG-LESS by the sovereign clock every ~30s (cwd = nishihost, runs as root like memhealer), CONNECT-probes each tier on loopback; a REFUSED port (dead listener) => fork + setsid + chdir(/volume1/ai/ galx) + execve the service with its CANONICAL args, DETACHED (parent returns, so the daemon reparents to init exactly like the originals). Connect-based liveness is deliberate: the kernel completes the TCP handshake for ANY bound listener, so a busy-but-alive daemon is NEVER falsely relaunched (no double-bind); only a truly dead port triggers a relaunch. It never deletes, never writes persistent/HW state -> never-brick BY CONSTRUCTION (rule 26). Arg-less = PRODUCTION (supervise the two real tiers). `<port> <path> [args...]` = TEST one service against a SPARE victim port (proves the exact relaunch mechanics with ZERO live risk). license_tier: ORIGINAL

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_itoa_lib.nx nx_connect.nx nx_gallery_gw_guard.nx

imports: nx_syscalls.nxnx_itoa_lib.nxnx_connect.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main gwg_atoi sys_mmap gwg_ensure gwg_port_alive sys_socket sys_set_socket_timeout sys_mmap ↻ sys_setsockopt sys_munmap sys_mmap ↻ nx_connect_bounded nx_fcntl sys_connect sys_mmap ↻ sys_poll sys_close gwg_launch sys_fork nx_setsid sys_chdir sys_mmap ↻ sys_openat_append sys_dup3 sys_mmap ↻ sys_execve sys_exit sys_poll ↻ gwg_puts sys_write gwg_slen gwg_putn nxi_fd sys_mmap ↻ ccz_cat_num sys_write ↻ sys_munmap ↻ sys_exit ↻ sys_now_realtime_sec sys_mmap ↻

structs

none

consts

17const GWG_CWD: *u8 = "/volume1/ai/galx"
18const GWG_SERVE: *u8 = "/volume1/ai/galx/nx_gallery_serve.elf"
19const GWG_GATEWAY: *u8 = "/volume1/ai/galx/nx_gallery_gateway.elf"
20const GWG_LAUNCHLOG: *u8 = "/volume1/ai/galx/gw.log"
21const GWG_STATUS: *u8 = "/volume1/homes/elderwesto/nishihost/gw_guard.log"
22const GWG_EVENTS: *u8 = "/volume1/homes/elderwesto/nishihost/gw_guard_events.log"
23const GWG_BACKEND_PORT: i64 = 18090
24const GWG_GATEWAY_PORT: i64 = 18190
25const GWG_PROBE_TMO_S: i64 = 3
26const GWG_MODE: i64 = 0x1a4 // 0644

functions

28func gwg_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
called by 1: gwg_puts
29func gwg_puts(fd: i64, s: *u8) -> i64 { sys_write(fd, s, gwg_slen(s)); return 0 }
called by 2: gwg_eventmain calls 2: sys_writegwg_slen
34func gwg_putn(fd: i64, v: i64) -> i64 { nxi_fd(fd, v); return 0 }
called by 2: gwg_eventmain calls 1: nxi_fd
35func gwg_atoi(s: *u8) -> i64 { var v: i64=0; var i: i64=0; while s[i]!=(0 as u8){ let c: i64=s[i] as i64; if c<48{return v} if c>57{return v} v=v*10+(c-48); i=i+1 } return v }
called by 1: main
38func gwg_event(now: i64, what: *u8) -> i64
49func gwg_port_alive(port: i64) -> i64
67func gwg_launch(path: *u8, argv: *i64) -> i64
83func gwg_ensure(port: i64, path: *u8, argv: *i64) -> i64
90func main(argc: i64, argv: *i64) -> i64