feat(windows): run as a real SCM service, not a Run-key autostart #107
Reference in New Issue
Block a user
Delete Branch "feat/windows-service"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
HKLM\…\Runlogin-time autostart with a real Windows service registered viasc create. Boot-time, SYSTEM context, auto-restart on crash (5s/5s/10s). Fixes the "every Windows debug session is blind" problem that stalled #102's tester cycle — the service now has a lifecycleGet-Servicecan see, instead of a user-session process with no stderr sink.main.rs's inline server body (~500 lines) intonuma::serve::run(config_path)so both the interactive CLI and the Windows service dispatcher drive the same startup loop.main.rsis now a thin sync dispatcher; each subcommand owns its own tokio runtime.src/windows_service.rswrapping Mullvad'swindows-servicecrate (Windows-only dep, feature-gated — zero impact on macOS/Linux binaries). ServiceMain spawns tokio on a dedicated thread, reportsRunning, handles Stop/Shutdown viarecv_timeout, reportsStopped.%PROGRAMDATA%\numa\bin\numa.exe(the user's Downloads folder is not a durable binPath for SCM).install_service_binarycopies into place idempotently;uninstall_windowsstops + deletes the service and removes the binary before restoring DNS.numa install/numa uninstall/numa service start|stop|restart|statusCLI shape — users see the same commands, only the underlying mechanism changes.Intentionally out of scope (separate PRs):
set dnsservers staticbug (clears interface DNS on probe failure)let _onnetsh add)Test plan
make all— fmt + clippy + audit + 285 lib tests, all passrust:1.94-bookworm) — binary builds clean with the refactornuma install→systemctl is-active numa=active (running),dig @127.0.0.1 google.comresolves correctly, journal shows newnuma::serve::/numa::ctx::module pathsnuma uninstallround-trip on Linux — resolv.conf restored from backup, service unit removed, DNS still worksnumaon macOS — binary starts, serves on loopback, stats API respondsnuma install(elevated) → reboot →Get-Service Numashows Running →dig @127.0.0.1 google.comresolves →numa uninstallcleans up.make deployon a fresh macOS box would cover it.