Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

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/cli.md +38−2

@@ -44,17 +44,19 @@ See [Change requests](change-requests.md), [Terminology and conventions](convent
44 44 ## Instance
45 45
46 46 ```sh
47 vole serve [--config <path>] [--log <level>]
47 vole serve [--config <path>] [--log <level>] [--log-file <path>]
48 48 ```
49 49
50 50 The listeners come from vole.toml: SSH for authenticated Git writes, HTTP
51 51 for the web and anonymous clone. It runs in the foreground and stops on
52 interrupt.
52 interrupt; under the Windows service manager it stops on the manager's
53 request instead.
53 54
54 55 | Option | Used by | Meaning |
55 56 |---|---|---|
56 57 | `-c, --config <path>` | — | the vole.toml to read; default is ./vole.toml, then ~/.vole/vole.toml |
57 58 | `--log <level>` | — | log level: debug, or the default info |
59 | `--log-file <path>` | — | append the log to this file instead of stderr, which a service needs |
58 60
59 61 See [Configuration](configuration.md), [Deploying](deploy/index.md).
60 62
@@ -282,6 +284,40 @@ because a backup that holds both is a backup of plaintext.
282 284
283 285 See [Operations § Back up an instance](operations.md#back-up-an-instance).
284 286
287 ### service
288
289 ```sh
290 vole service install --config <path> [--account <account>] [--log-file <path>]
291 vole service uninstall
292 vole service start
293 vole service stop
294 vole service status
295 ```
296
297 `install` — Registers `Vole` with the Windows service manager to run this binary as
298 `serve --config <path> --log-file <path>`, and prepares what the service
299 account needs: the data directory, the log directory, and read access to the
300 configuration file. The service starts automatically, after a short delay,
301 and is restarted if it fails. It needs an elevated prompt.
302 `data_dir` must be an absolute path: a service starts in %SystemRoot%\System32,
303 not in the directory it was installed from.
304
305 `uninstall` — Stops the service if it is running and removes it. The data directory and the configuration file are left in place.
306
307 `start` — Starts the installed service and waits until it reports running.
308
309 `stop` — Stops the service and waits until it reports stopped. A CI job that is draining is allowed to finish first.
310
311 `status` — Prints the state the service manager reports, and the command line it runs.
312
313 | Option | Used by | Meaning |
314 |---|---|---|
315 | `-c, --config <path>` | install | the vole.toml to read; default is ./vole.toml, then ~/.vole/vole.toml |
316 | `--account <account>` | install | the account the service runs as (default NT SERVICE\Vole) |
317 | `--log-file <path>` | install | where the service appends its log (default <data_dir>/logs/serve.log) |
318
319 See [Deploy on Windows](deploy/windows.md), [Packages and upgrades](packaging.md).
320
285 321 ### whoami
286 322
287 323 ```sh