code wiki / _hdl_build / nx_gallery_gw_guard.nx
nx_gallery_gw_guard.nx
buildroot/runtime/_hdl_build/nx_gallery_gw_guard.nx
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
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
structs
| none |
consts
| 17 | const GWG_CWD: *u8 = "/volume1/ai/galx" |
| 18 | const GWG_SERVE: *u8 = "/volume1/ai/galx/nx_gallery_serve.elf" |
| 19 | const GWG_GATEWAY: *u8 = "/volume1/ai/galx/nx_gallery_gateway.elf" |
| 20 | const GWG_LAUNCHLOG: *u8 = "/volume1/ai/galx/gw.log" |
| 21 | const GWG_STATUS: *u8 = "/volume1/homes/elderwesto/nishihost/gw_guard.log" |
| 22 | const GWG_EVENTS: *u8 = "/volume1/homes/elderwesto/nishihost/gw_guard_events.log" |
| 23 | const GWG_BACKEND_PORT: i64 = 18090 |
| 24 | const GWG_GATEWAY_PORT: i64 = 18190 |
| 25 | const GWG_PROBE_TMO_S: i64 = 3 |
| 26 | const GWG_MODE: i64 = 0x1a4 // 0644 |
functions
| 28 | func 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 |
| 29 | func gwg_puts(fd: i64, s: *u8) -> i64 { sys_write(fd, s, gwg_slen(s)); return 0 } |
| 34 | func gwg_putn(fd: i64, v: i64) -> i64 { nxi_fd(fd, v); return 0 } |
| 35 | func 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 |
| 38 | func gwg_event(now: i64, what: *u8) -> i64 |
| 49 | func gwg_port_alive(port: i64) -> i64 called by 1: gwg_ensure calls 5: sys_socketsys_set_socket_timeoutsys_mmapnx_connect_boundedsys_close |
| 67 | func gwg_launch(path: *u8, argv: *i64) -> i64 |
| 83 | func gwg_ensure(port: i64, path: *u8, argv: *i64) -> i64 |
| 90 | func main(argc: i64, argv: *i64) -> i64 |