New _spawn_detached(argv, pid_file) helper uses Popen with start_new_session=True + close_fds=True + DEVNULL stdio to launch a DECNET subcommand as a fully independent process. The parent does NOT wait(); if it dies the child survives under init. This is deliberately not a supervisor — if the child dies the operator restarts it manually. _pid_dir() picks /opt/decnet when writable else ~/.decnet, so both root-run production and non-root dev work without ceremony. `decnet agent` now auto-spawns `decnet forwarder --daemon ...` as that detached sibling, pulling master host + syslog port from DECNET_SWARM_MASTER_HOST / DECNET_SWARM_SYSLOG_PORT. --no-forwarder opts out. If DECNET_SWARM_MASTER_HOST is unset the auto-spawn is silently skipped (single-host dev or operator wants to start the forwarder separately). tests/test_auto_spawn.py monkeypatches subprocess.Popen and verifies: the detach kwargs are passed, the PID file exists and contains a valid positive integer (PID-file corruption is a real operational headache — catching bad writes at the test level is free), the --no-forwarder flag suppresses the spawn, and the unset-master-host path silently skips.
5.5 KiB
5.5 KiB