Install and run Vole as a Windows service
What
A Windows forge has to start without a person logged in, survive a reboot, and
stop cleanly when Windows shuts down. Today vole serve is a console process: on
the Server Core guest it runs from a scheduled task because a process started from
an SSH session is killed with that session (Windows puts each session in a job
object), and nothing tells the SCM what state it is in.
This issue is the service half. Packaging is #408.
Decisions
- The binary speaks the SCM itself.
golang.org/x/sys/windows/svcis already in the module graph, soservecan dispatch throughsvc.Runwhensvc.IsWindowsService()is true and stay a console program otherwise —systemd/launchdparity with no wrapper. NSSM or WinSW would add a second executable and an opaque layer; a scheduled task has no recovery, dependency, or stop semantics. - The default identity is the virtual account
NT SERVICE\Vole, named after the service. No password to store or rotate, least privilege, and it is the “process user” the access-list check ininternal/securealready trusts alongsideSYSTEMandAdministrators. Not LocalSystem: a network-facing forge as SYSTEM is the Windows version of running the Linux package as root.--accountstays open for managed deployments. - Install, remove, start, stop, and status are CLI verbs, so a zip or hand-built install works without an MSI, and the MSI can call the same commands rather than keeping a second definition of the service.
- Logs go to a file, because a service has no stderr. The install command
writes
--log-fileinto the service command line, defaulting to<data_dir>/logs/serve.log, and lifecycle or fatal errors also go to the Application event log so a failed start is diagnosable. - The installer does not open the firewall, matching the Linux package not
touching
/etc/ssh. The deploy page prints the rules. - The supported SSH mode on Windows is the built-in listener
(
ssh_listen = "tcp", the default). The portless sshd arrangement is still unix-shaped (#406).
Scope
serve --log-file <path>: a file sink for the logger, opened throughinternal/secureso the log is not readable by everyone; stderr remains the default for a console run.- SCM dispatch in
serve:StartPending→Running(accept Stop|Shutdown),Stop/Shutdowncancels the contextservealready builds, reportsStopPendingwhile runners drain, thenStopped. A server that exits on its own exits nonzero so recovery actions fire. vole service install|uninstall|start|stop|status:- install: requires an elevated process; creates the service as
NT SERVICE\<name>with auto (delayed) start, description, recovery (restart ×3), and a restricted service SID; prepares the data directory and the config file’s access list for that SID; installs the event-log source. - uninstall: stops a running service, deletes it, leaves the data directory and says where it is.
- start/stop: await the state instead of returning at the control call.
- On non-Windows, the command exists and answers that services are a Windows concept, so the generated reference is the same everywhere.
- install: requires an elevated process; creates the service as
- An exported Windows-only helper in
internal/secureto write a protected access list naming a given set of SIDs, for the installer that prepares a directory for an account that is not the current process; the runtime verification is unchanged. docs/deploy/windows.md: install from a release binary,vole service install, firewall rules,ssh_listen = "tcp", what is not supported (runner, sshd front door), and the lack of Authenticode signing (#408).
Acceptance criteria
- On the Server Core guest:
vole service install --config …creates and starts the service;statusreports running; the log file exists with a restricted ACL;stopdrains and stops;uninstallremoves the service and leaves the data directory; a VM reboot brings the forge back without logging in. - Startup failures (invalid config, busy port) are visible in the event log and the service exits nonzero.
- Unix behaviour is unchanged:
servestill stops on interrupt, and the mode table and generated reference still passvole workflow checkand thecli referencestep. VOLE_INSECURE_HOST_KEY-free verification on the guest: HTTP, admin CLI over SSH, and a git push.
Out of scope
The MSI, install.ps1, Authenticode signing, winget, and the CI runner on
Windows.