vole
Site
Clone
Read only, no credentials:
https://rodent.software/vole.git
Write over SSH with a registered key:
git clone ssh://git@rodent.software/vole.git
Self-hosted forge that lives in your Git repo.
Run the forge as a Windows service
9cbfa891425adaa3e2769d1b3f88d5f211190dc6 · Keenan Nemetz · 2d ago · parent 33cbbc9d
Run the forge as a Windows service The Windows server ran from a scheduled task because a process started from an SSH session dies with it, and nothing told the service manager what state the forge was in. This makes `serve` a real service and gives it the commands to install itself. The binary now speaks the SCM: `svc.IsWindowsService` decides, `svc.Run` is entered before any work so a slow instance is a pending state rather than a dispatcher timeout, and a Stop or Shutdown cancels the same context an interrupt cancels, which is what lets the drain finish. The service reports running before the listeners are up, so a bind failure arrives as a nonzero exit and the recovery actions installed with it restart the forge; start and stop failures also go to the Application event log, because a service has no stderr. `vole service install|uninstall|start|stop|status` manages the registration with no wrapper and no second definition: auto start with the standard delay, a description, three restarts as recovery, and the virtual account `NT SERVICE\Vole` with a restricted SID. Install also prepares what that account needs — the data directory and everything already in it, the log directory, and read access to the configuration — through `secure.HardenFor`, a new Windows-only helper that writes a protected access list for principals the running process is not. An instance initialized by a person is readable by the service afterwards, which is the upgrade case, not only the fresh one. `serve --log-file` is the file sink the service needs, opened through the secret store so it is not readable by everyone; the console keeps stderr. The command exists off Windows too and answers that services are the platform's business, so the generated reference is the same everywhere. Verified on the Server Core 2022 guest (full record on the issue): install, start, status, stop, uninstall; the data directory, database, key, and log granted only to the service account, SYSTEM, and Administrators; HTTP 200 through the forwarded port; admin CLI and git push over Vole's SSH listener; a reboot brought the forge back with no login; and a second install refuses with a clear message. The Windows-only unit tests (`stateName`, `lookupSID`) pass there too, and `vole workflow run verify` passes locally. Part of 01M8SE6PR5N7M3X48SMAGA8Z18. Packaging, Authenticode, and winget are 01M8SE6GWX1DGYPY6H9YC142C2.
docs/deploy/windows.md +172
| @@ -0,0 +1,172 @@ | |||
| 1 | # Deploy Vole on Windows | ||
| 2 | |||
| 3 | Windows support covers the forge server and the CLI client, not the CI runner. | ||
| 4 | There is no installer or package yet | ||
| 5 | ([#408](https://rodent.software/vole/n/408) tracks that), so this page installs | ||
| 6 | a release binary by hand and registers it as a Windows service. Everything that needs an elevated prompt is | ||
| 7 | marked; a Server Core machine is enough. | ||
| 8 | |||
| 9 | Authenticode signing does not exist yet, so Windows will warn about an unknown | ||
| 10 | publisher the first time the binary runs. Verify the download against the | ||
| 11 | release's GPG-signed `SHA256SUMS` instead of trusting the prompt. | ||
| 12 | |||
| 13 | ## What you need | ||
| 14 | |||
| 15 | - Windows Server 2019 or later, or Windows 10/11 for a laptop forge, `amd64`. | ||
| 16 | - **Git for Windows** with `git.exe` on the machine `PATH`. The server shells out | ||
| 17 | to git for every push, clone, and metadata write; nothing works without it. | ||
| 18 | - The `vole.exe` binary. Until packages exist, build it from the release tag or | ||
| 19 | this checkout: | ||
| 20 | |||
| 21 | ```sh | ||
| 22 | GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -o vole.exe ./cmd/vole | ||
| 23 | ``` | ||
| 24 | |||
| 25 | - A DNS name such as `forge.example.com` if you want HTTPS. | ||
| 26 | - An elevated PowerShell for the install and the service commands. | ||
| 27 | |||
| 28 | ## 1. Put the binary in place | ||
| 29 | |||
| 30 | ```powershell | ||
| 31 | New-Item -ItemType Directory -Force 'C:\Program Files\Vole' | Out-Null | ||
| 32 | Copy-Item .\vole.exe 'C:\Program Files\Vole\vole.exe' | ||
| 33 | & 'C:\Program Files\Vole\vole.exe' version | ||
| 34 | ``` | ||
| 35 | |||
| 36 | The service command line uses absolute paths, so nothing has to be added to | ||
| 37 | `PATH`. Add `C:\Program Files\Vole` to it if you want to type `vole` yourself. | ||
| 38 | |||
| 39 | ## 2. Write the configuration | ||
| 40 | |||
| 41 | `vole service install` requires every path in the configuration to be absolute: | ||
| 42 | a service starts in `%SystemRoot%\System32`, not in the directory you installed | ||
| 43 | from, so `data_dir = "./data"` would land somewhere nobody meant. | ||
| 44 | |||
| 45 | ```powershell | ||
| 46 | New-Item -ItemType Directory -Force 'C:\ProgramData\Vole' | Out-Null | ||
| 47 | @' | ||
| 48 | data_dir = 'C:\ProgramData\Vole\data' | ||
| 49 | http_addr = ":80" | ||
| 50 | https_addr = ":443" | ||
| 51 | public_url = "https://forge.example.com" | ||
| 52 | acme_email = "you@example.com" | ||
| 53 | ssh_addr = "0.0.0.0:2222" | ||
| 54 | '@ | Set-Content 'C:\ProgramData\Vole\vole.toml' | ||
| 55 | ``` | ||
| 56 | |||
| 57 | Windows has no privileged ports, so binding 80 and 443 needs no capability | ||
| 58 | change. Leave `ssh_listen` at its default `"tcp"`: the sshd front door is | ||
| 59 | unix-only for now, and clone URLs therefore carry `:2222`. Portless clone URLs | ||
| 60 | need that work first. | ||
| 61 | |||
| 62 | ## 3. Initialize the instance and its first admin | ||
| 63 | |||
| 64 | Run these as the administrator who will own the instance. The service install | ||
| 65 | step below rewrites the files' access lists for the service account afterwards, | ||
| 66 | so the order matters only in that the instance must exist first. | ||
| 67 | |||
| 68 | ```powershell | ||
| 69 | $cfg = 'C:\ProgramData\Vole\vole.toml' | ||
| 70 | & 'C:\Program Files\Vole\vole.exe' admin init --config $cfg | ||
| 71 | & 'C:\Program Files\Vole\vole.exe' admin --config $cfg account create admin ` | ||
| 72 | --key "$env:USERPROFILE\.ssh\id_ed25519.pub" --role admin | ||
| 73 | ``` | ||
| 74 | |||
| 75 | `init` also creates the `vole-instance` repository that holds instance | ||
| 76 | customization. It is local-only and never available over `--remote`. | ||
| 77 | |||
| 78 | ## 4. Install the service (elevated) | ||
| 79 | |||
| 80 | ```powershell | ||
| 81 | & 'C:\Program Files\Vole\vole.exe' service install --config 'C:\ProgramData\Vole\vole.toml' | ||
| 82 | & 'C:\Program Files\Vole\vole.exe' service start | ||
| 83 | & 'C:\Program Files\Vole\vole.exe' service status | ||
| 84 | ``` | ||
| 85 | |||
| 86 | `service install` registers a service named `Vole` that starts automatically | ||
| 87 | after a short delay, with recovery actions that restart it after a failure, and | ||
| 88 | runs as the virtual account `NT SERVICE\Vole`: | ||
| 89 | |||
| 90 | | What | Where | | ||
| 91 | |---|---| | ||
| 92 | | Service | `Vole`, runs `<exe> serve --config <path> --log-file <path>` | | ||
| 93 | | Account | `NT SERVICE\Vole` (`--account` for a domain account) | | ||
| 94 | | Data | the configured `data_dir` | | ||
| 95 | | Log | `<data_dir>\logs\serve.log` by default (`--log-file` to change it) | | ||
| 96 | | Event Log | source `Vole` in the Application log, for start and stop failures | | ||
| 97 | |||
| 98 | The install prepares the access lists the service account needs: the data | ||
| 99 | directory and everything already in it, the log directory, and read access to | ||
| 100 | the configuration file. The lists name only the service account, | ||
| 101 | `NT AUTHORITY\SYSTEM`, and `BUILTIN\Administrators`, and the service verifies | ||
| 102 | them again when it starts — an instance that cannot protect its secrets refuses | ||
| 103 | to serve them. | ||
| 104 | |||
| 105 | `service uninstall` stops and removes the service and leaves the data directory | ||
| 106 | and configuration in place. Removing those is a deliberate act. | ||
| 107 | |||
| 108 | ## 5. Open the firewall (elevated) | ||
| 109 | |||
| 110 | The installer does not change firewall rules, the same way the Linux package | ||
| 111 | leaves your sshd alone. | ||
| 112 | |||
| 113 | ```powershell | ||
| 114 | foreach ($p in 80, 443, 2222) { | ||
| 115 | New-NetFirewallRule -Name "vole-$p" -DisplayName "Vole $p" ` | ||
| 116 | -Direction Inbound -Protocol TCP -LocalPort $p -Action Allow | ||
| 117 | } | ||
| 118 | ``` | ||
| 119 | |||
| 120 | Open 22 instead of 2222 only if you later put the system `sshd` in front of Vole. | ||
| 121 | Close 80 once ACME has issued the certificate if you terminate HTTPS only on 443. | ||
| 122 | |||
| 123 | ## 6. Verify | ||
| 124 | |||
| 125 | ```powershell | ||
| 126 | curl.exe -sS -o NUL -w "%{http_code}`n" https://forge.example.com/ | ||
| 127 | & 'C:\Program Files\Vole\vole.exe' service status | ||
| 128 | Get-Content 'C:\ProgramData\Vole\data\logs\serve.log' -Tail 20 | ||
| 129 | ``` | ||
| 130 | |||
| 131 | From your computer, enroll the admin and push something: | ||
| 132 | |||
| 133 | ```sh | ||
| 134 | vole admin --remote ssh://git@forge.example.com:2222 account invite admin | ||
| 135 | vole admin --remote ssh://git@forge.example.com:2222 repo create demo | ||
| 136 | git clone ssh://git@forge.example.com:2222/demo.git | ||
| 137 | ``` | ||
| 138 | |||
| 139 | ## Upgrading | ||
| 140 | |||
| 141 | ```powershell | ||
| 142 | & 'C:\Program Files\Vole\vole.exe' service stop | ||
| 143 | Copy-Item .\vole.exe 'C:\Program Files\Vole\vole.exe' -Force | ||
| 144 | & 'C:\Program Files\Vole\vole.exe' service start | ||
| 145 | ``` | ||
| 146 | |||
| 147 | Database migrations run on start and cannot be rolled back by installing an | ||
| 148 | older binary, so [back up the instance](../operations.md#back-up-an-instance) first. | ||
| 149 | When the MSI exists this becomes an in-place upgrade; until then the binary is | ||
| 150 | the only thing replaced. | ||
| 151 | |||
| 152 | ## What is not supported yet | ||
| 153 | |||
| 154 | - **The CI runner.** Container jobs need a container runtime; Windows containers | ||
| 155 | and WSL2 are a different architecture rather than a port. The forge serves | ||
| 156 | repositories and queues nothing it cannot build elsewhere. | ||
| 157 | - **The sshd front door** (`ssh_listen = "socket"`). It uses a unix-domain | ||
| 158 | socket, `exec`, and file modes; the built-in listener is the supported mode. | ||
| 159 | - **Packaging, signing, and winget.** There is no MSI, no `install.ps1`, and no | ||
| 160 | Authenticode signature yet; [#408](https://rodent.software/vole/n/408) is the | ||
| 161 | plan. | ||
| 162 | |||
| 163 | ## Troubleshooting | ||
| 164 | |||
| 165 | - The service did not start: `vole service status` prints its state and command | ||
| 166 | line, and the Application event log has the error. Running the printed command | ||
| 167 | in an elevated console shows the same failure on stderr. | ||
| 168 | - `access is denied` on the data directory: something other than | ||
| 169 | `service install` changed the files' access lists. Re-run `service install` to | ||
| 170 | rewrite them, or compare with `Get-Acl`. | ||
| 171 | - The service starts but git operations fail: `git.exe` is not on the machine | ||
| 172 | `PATH`. Services read the machine environment, not a user's. | ||