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.
cmd/vole/service_test.go +30
| @@ -0,0 +1,30 @@ | |||
| 1 | //go:build !windows | ||
| 2 | |||
| 3 | package main | ||
| 4 | |||
| 5 | import ( | ||
| 6 | "strings" | ||
| 7 | "testing" | ||
| 8 | ) | ||
| 9 | |||
| 10 | // TestServiceIsWindowsOnly pins the answer a unix user gets. The verbs are in the | ||
| 11 | // command table everywhere so the generated reference does not depend on the | ||
| 12 | // platform that built the binary, but the service manager is Windows's business. | ||
| 13 | func TestServiceIsWindowsOnly(t *testing.T) { | ||
| 14 | err := cmdService([]string{"status"}) | ||
| 15 | if err == nil { | ||
| 16 | t.Fatal("vole service status succeeded outside Windows") | ||
| 17 | } | ||
| 18 | if !strings.Contains(err.Error(), "Windows") { | ||
| 19 | t.Fatalf("the error does not say the command is Windows-only: %v", err) | ||
| 20 | } | ||
| 21 | } | ||
| 22 | |||
| 23 | // TestServiceRejectsFlagsTheSubcommandDoesNotTake keeps the shared decode table | ||
| 24 | // honest: `service status` reads no options, so a config path is a mistake | ||
| 25 | // rather than something to ignore. | ||
| 26 | func TestServiceRejectsFlagsTheSubcommandDoesNotTake(t *testing.T) { | ||
| 27 | if err := cmdService([]string{"status", "--config", "vole.toml"}); err == nil { | ||
| 28 | t.Fatal("service status accepted --config") | ||
| 29 | } | ||
| 30 | } | ||