Skip to content

feat(server): run as a native Windows service, no NSSM - #802

Merged
fclairamb merged 14 commits into
mainfrom
feat/windows-service
Nov 7, 2026
Merged

fclairamb merged 14 commits into
mainfrom
feat/windows-service

Conversation

@fclairamb

@fclairamb fclairamb commented Nov 7, 2026 •

Copy link
Copy Markdown
Owner

Windows installs no longer need NSSM. solidping.exe registers itself as a native service:

solidping service install   # admin prompt
solidping service start

The old "sc.exe (Native)" recipe on the docs page never worked: the binary did not talk to the Service Control Manager, so it failed with error 1053 after 30 s.

Spec: specs/done/2026/11/2026-11-07-04-native-windows-service.md.

What changes

  • solidping service install|uninstall|start|stop, plus a hidden service run that the SCM launches. Hidden on other platforms, where each subcommand returns an "only supported on Windows" error.
  • The service runs from a data folder, %ProgramData%\SolidPing by default. config.yml, the SQLite database and the files resolve there. install creates it readable only by SYSTEM and Administrators (ProgramData lets every local user read).
  • Configuration goes in config.yml, not in the service's registry environment, which any local user can read.
  • Logs go to logs\solidping.log (rotated, 20 MB x 3). Go crash output goes to logs\crash.log, since a service has no console.
  • Stop and Shutdown cancel the server context, the same graceful path as SIGTERM. Recovery restarts it after a failure, including an exit with an error.
  • The devloop rotating writer moved to internal/rotatelog so both use it. No behaviour change for devloop.
  • serve now takes its log writer from serveTo(ctx, io.Writer). Same behaviour.
  • Docs: the Windows page uses service install, with a short note on moving off NSSM.

Tests

  • Unit tests for the helpers, the off-Windows errors and the SCM handler (stop cancels the run, a failed run exits with code 1).
  • New windows-service CI job on windows-2025: runs the tests, then a real install, ACL check, start, /api/mgmt/health, stop, log check and uninstall. CI lints only on Linux, so I ran GOOS=windows golangci-lint locally: 0 issues.

🤖 Generated with Claude Code

fclairamb and others added 3 commits November 7, 2026 23:53
The Windows service needs the same size-rotated log file. No behaviour change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`solidping service install|uninstall|start|stop` registers solidping.exe
with the Service Control Manager, so NSSM is no longer needed. The service
runs `service run`, which enters the data folder (%ProgramData%\SolidPing
by default, created with a SYSTEM + Administrators only ACL), writes
rotated logs and crash output under logs\, and maps Stop/Shutdown to the
same graceful shutdown as SIGTERM. Recovery restarts it on failure.

A windows-service CI job runs the tests and a real install, start, health
check, stop and uninstall on a Windows runner.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@fclairamb
fclairamb marked this pull request as ready for review November 7, 2026 23:01
fclairamb and others added 3 commits November 8, 2026 00:05
The Windows Service section now uses `solidping service install|start|stop|uninstall`
with config.yml in %ProgramData%\SolidPing. The NSSM recipe and the broken sc.exe one
are gone; a short note explains how to switch from NSSM. Directory, logs, upgrade and
troubleshooting sections follow the data folder.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@codecov

codecov Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.34884% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.24%. Comparing base (03fcf88) to head (9ff9fb2).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
server/main.go 60.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #802      +/-   ##
==========================================
- Coverage   89.24%   89.24%   -0.01%     
==========================================
  Files        1323     1326       +3     
  Lines      135516   135615      +99     
==========================================
+ Hits       120943   121025      +82     
- Misses      14564    14581      +17     
  Partials        9        9              
Files with missing lines Coverage Δ
server/cmd_service.go 100.00% <100.00%> (ø)
server/cmd_service_other.go 100.00% <100.00%> (ø)
server/internal/rotatelog/rotatelog.go 90.47% <100.00%> (ø)
server/main.go 70.72% <60.00%> (+0.17%) ⬆️

... and 21 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@fclairamb

Copy link
Copy Markdown
Owner Author

Tested on a real Windows 11 machine

Windows 11 Pro (build 26300, French locale), Surface Laptop, admin account over SSH. Binary built from this branch (bd355e8dd, windows/amd64), installed as C:\Program Files\SolidPing\solidping.exe. Clean machine: no previous service or data folder.

Step Result Detail
service run from a console ✅ exit 1, points at solidping serve
service install ✅ prints config and log paths
Registered service ✅ "C:\Program Files\SolidPing\solidping.exe" service run --name SolidPing --dir C:\ProgramData\SolidPing, Auto, LocalSystem
Recovery actions ✅ restart after 5000 ms x3, reset 86400 s, also on non-crash failures
Data folder ACL ✅ inheritance blocked, FullControl for SYSTEM (S-1-5-18) and Administrators (S-1-5-32-544) only
service install again ✅ refused, "already exists"
config.yml in the data folder ✅ server.listen: ':4100' was used
service start ✅ Running, /api/mgmt/version answers 0.44.3-pr802
/api/mgmt/health ✅ HTTP 200
Database and logs ✅ C:\ProgramData\SolidPing\solidping.db, logs\solidping.log
Process killed with Stop-Process -Force ✅ restarted by the SCM, new PID, answers again
Restart-Service SolidPing ✅ Running
service stop ✅ stopped in 2 s, graceful shutdown in the log, port closed
Crash output ✅ crash.log empty
service uninstall ✅ service removed, solidping.db kept

Service log on startup:

level=INFO msg="SolidPing is ready" url=http://localhost:4100 listen=[::]:4100 version=0.44.3-pr802 database="sqlite C:\\ProgramData\\SolidPing\\solidping.db"
level=INFO msg="Shutting down server" timeout=30s
level=INFO msg="All runners stopped"

The machine was cleaned up afterwards (service, data folder and binary removed).

🤖 Generated with Claude Code

@fclairamb
fclairamb enabled auto-merge (squash) November 7, 2026 23:35
@fclairamb
fclairamb merged commit c66c947 into main Nov 7, 2026
36 checks passed
@fclairamb
fclairamb deleted the feat/windows-service branch November 7, 2026 23:52
fclairamb added a commit that referenced this pull request Nov 8, 2026
The macOS follow-up to #802: `solidping service
install|uninstall|start|stop` now work on macOS, through launchd.

```bash
sudo solidping service install   # daemon: starts at boot, runs as root
sudo solidping service start
```

Without `sudo`, the same commands install a launchd agent of the current
user, which starts at login.

Spec: `specs/done/2026/11/2026-11-08-06-native-macos-service.md`.

## What changes

- **launchd job.** `install` writes
`/Library/LaunchDaemons/io.solidping.plist` (or
`~/Library/LaunchAgents/` without sudo). `start` / `stop` are `launchctl
bootstrap` / `bootout`. `stop` waits until launchd has let the server
go. The plist stays, so a stopped service starts again at the next boot,
like a Windows service with automatic start.
- **Restart on failure only.** `KeepAlive {SuccessfulExit: false}` and
`ThrottleInterval` 5 s: a failed run restarts after 5 s, a clean stop
(SIGTERM) does not. The server gets 30 s to close (`ExitTimeOut`).
- **Data folder.** `/Library/Application Support/SolidPing` by default
(`~/Library/...` for an agent), created `0700`. `config.yml` and the
SQLite database live there. No `EnvironmentVariables` in the plist,
which is world-readable.
- **Logs.** Same handling as Windows, now shared in `enterServiceDir`
(`cmd_service_run.go`): rotated `logs/solidping.log` and
`logs/crash.log`. `logs/launchd.log` only captures what fails before
solidping takes over its logs.
- **Gatekeeper.** `install` warns when the binary still carries
`com.apple.quarantine`.
- **Label.** The `--name` default is `io.solidping` on macOS, the label
the old hand-written recipe used. `service` is still hidden on Linux,
where it returns `services are only supported on Windows and macOS`.
- `serviceRun` now takes the command's context on every platform. The
Windows behaviour doesn't change.
- **Docs.** The macOS page now covers `service install`, the user-agent
variant, `brew services`, and a migration note for anyone using the old
hand-written plist.

Companion PR: fclairamb/homebrew-tap#5 adds the `service do` block that
`brew services start solidping` needs. It works with the current
release.

## Tests

- Platform-neutral unit tests: plist rendering (including XML escaping),
launchd domains and paths, default folder and label per OS. Darwin
tests: `service run` is refused outside launchd, and the data folder
mode.
- **By hand on macOS 27.2, as a user agent on a spare port:** install
(folder `0700`), start, `/api/mgmt/health` OK, a second start
(kickstart), stop (job unloaded, graceful-shutdown lines in the log),
uninstall (plist removed), and `service run` refused from a terminal.
With a broken `config.yml`, launchd restarted it every 5 s (`runs = 3`,
exit code 1).
- **New `macos-service` CI job on `macos-15`:** covers the `sudo` daemon
path, which I couldn't run here. It runs the tests, then a real install,
`plutil -lint`, root-only folder check, start, health, stop, log and DB
checks, and uninstall.
- `golangci-lint run ./...` is clean, and so is the main package with
`GOOS=windows` and `GOOS=linux`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
fclairamb added a commit that referenced this pull request Nov 9, 2026
The Linux follow-up to #802 (Windows) and #811 (macOS): `solidping
service install|uninstall|start|stop` now work on Linux, through
systemd.

```bash
sudo mv solidping /usr/local/bin/
sudo solidping service install   # system unit, enabled: starts at boot as user `solidping`
sudo solidping service start
```

Without `sudo`, the same commands install a systemd user unit of the
current user.

Spec: `specs/done/2026/11/2026-11-09-01-native-linux-service.md`.

## What changes

- **systemd unit.** `install` writes
`/etc/systemd/system/solidping.service` (or `~/.config/systemd/user/`
without sudo), then `daemon-reload` and `enable`. `start` / `stop` are
`systemctl start` / `stop` (stop blocks until the server is gone).
`uninstall` is `disable --now`, then it removes the unit.
- **Dedicated user.** Unlike the macOS daemon, the system unit does not
run as root: `install` creates a `solidping` system account when missing
(`useradd --system`, no login, no home). The unit gets `CAP_NET_RAW`
(ICMP raw fallback, traceroute) and `CAP_NET_BIND_SERVICE` (ports below
1024) as ambient capabilities, plus `NoNewPrivileges`, `PrivateTmp`,
`ProtectSystem=strict` with `ReadWritePaths=<data folder>`,
`UMask=0077`.
- **Restart on failure only.** `Restart=on-failure`, `RestartSec=5`,
`TimeoutStopSec=30`, the same values as the other platforms.
- **Data folder.** `/var/lib/solidping` by default
(`$XDG_DATA_HOME/solidping` for a user unit), created `0700` and handed
to `solidping`. An existing folder is kept, with a `chown` hint if
`solidping` does not own it. No secrets in the unit, which is
world-readable.
- **Logs go to the journal.** journald already rotates and timestamps
logs, so `service run` on Linux only enters the data folder and serves
to stdout: `journalctl -u solidping`.
- **Guards.** `service run` is refused outside systemd (no
`INVOCATION_ID`). `install` refuses a host not booted with systemd, a
`--name` systemd would reject or that leaves the unit folder, and a data
folder path with spaces, quotes or backslashes. `ExecStart` arguments
are quoted, and `%`/`$` are escaped. It warns when the `solidping` user
can't reach the binary (e.g. it is under `/root`).
- `service` is now hidden only on the remaining platforms (BSD):
`services are only supported on Windows, macOS and Linux`.
- **Docs.** The hand-written unit on the Linux page is replaced by
`service install`, with sections on the user unit, `systemctl edit`
drop-ins (e.g. `EnvironmentFile=`), migrating from the old unit (`--dir
/opt/solidping` keeps its data), updating and file storage.

## Tests

- Platform-neutral unit tests: unit rendering (system and user),
argument quoting, name and path checks, unit paths, default folder and
name. Linux tests: `service run` refused outside systemd, the data
folder mode, the binary reachability check.
- **By hand in an Ubuntu 24.04 container booted with systemd:** the
system unit (user created, folder `solidping 700`, `systemd-analyze
verify`, start, `/api/mgmt/health` OK, running as `solidping` with
`CapAmb` = `NET_RAW` + `NET_BIND_SERVICE`, stop with the
graceful-shutdown lines in the journal, a broken `config.yml` restarted
every 5 s with exit code 1, back up after a container reboot,
uninstall). Also the user unit with lingering (runs as the user, journal
via `--user`), and every warning and refusal above.
- **New `linux-service` CI job on `ubuntu-26.04`:** the system unit
cycle on a real systemd host (install, verify, enabled, folder owner and
mode, start, health, user, stop, journal and DB checks, uninstall). It
gates `ci`.
- `golangci-lint run` is clean with `GOOS=linux`, `darwin`, `windows`
and `freebsd`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
fclairamb added a commit that referenced this pull request Nov 9, 2026
… control (#817)

Fixes GHSA-2j47-9jj8-63vr (only `main` since #802 is affected; no
release ships the native Windows service yet).

`solidping service install` left an existing data folder (default
`C:\ProgramData\SolidPing`) as it was. Any local user can create that
folder before the install and stays its owner, so they could read the
LocalSystem service's secrets or supply its `config.yml`.

**Fix** (`server/cmd_service_windows.go`): an existing folder is reused
only when it is
- a plain folder, not a link or a junction (opened with
`FILE_FLAG_OPEN_REPARSE_POINT`, so nothing is followed);
- owned by SYSTEM, Administrators or the installing user;
- protected (no inheritance) with allow rules for SYSTEM and
Administrators only;
- and everything inside is neither a link nor owned by someone else, nor
opened to another account.

Otherwise install fails before registering the service, with the reason
and "delete the folder or choose another `--dir`". Re-applying the ACL
alone would not do: the owner can always rewrite it.

**Tests** (`cmd_service_windows_test.go`, run by the `Windows service`
job, skipped without an elevated token):
- positive control: a folder from a previous install, with files and
folders added since, is reused;
- refused: inherited ACL, extra grant to Users, a file instead of a
folder, a junction to a protected folder, a junction inside, a child
granting Users, an untrusted owner.
- The CI job now also reinstalls on the folder the service filled (must
pass) and installs on a pre-created folder (must fail, no service
registered).

**Docs:** `installation/windows.md` explains when an existing folder is
reused, and the NSSM migration now says to copy files rather than move
them, since a moved file keeps its old ACL.

**Not checked locally:** the Windows code only runs on Windows. Locally
it passes `GOOS=windows go vet`, a test compile and `golangci-lint`. The
`Windows service` CI job is its real test.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
fclairamb added a commit that referenced this pull request Nov 9, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.45.0](v0.44.3...v0.45.0)
(2026-11-09)


### Features

* dashboard glance strips, failed sign-in account names, log noise fixes
([#824](#824))
([659c52c](659c52c))
* **dashboard:** 24h / 7d / 30d availability window, saved per user
([#821](#821))
([283a28e](283a28e))
* **mcp:** sharpen tool descriptions for Glama scoring
([#825](#825))
([ca305f1](ca305f1))
* **server:** run as a native Linux systemd service
([#819](#819))
([8a0cb2f](8a0cb2f))
* **server:** run as a native macOS launchd service
([#811](#811))
([c6612ea](c6612ea))
* **server:** run as a native Windows service, no NSSM
([#802](#802))
([c66c947](c66c947))
* **telegram:** explicit /support mode instead of capturing every
message ([#820](#820))
([571607e](571607e))


### Bug Fixes

* **auth:** admit by email address only when the email is verified
([#818](#818))
([91992fe](91992fe))
* batch of production-log and Slack issues
([#808](#808))
([580d09c](580d09c))
* **deps:** update github.com/dop251/goja digest to d6eaa50
([#800](#800))
([60b7443](60b7443))
* **deps:** update github.com/dop251/goja digest to d8dfb4d
([#810](#810))
([e11b926](e11b926))
* **deps:** update go dependencies (non-major)
([#806](#806))
([1c59927](1c59927))
* **deps:** update go dependencies (non-major)
([#822](#822))
([ec0aebf](ec0aebf))
* **deps:** update module github.com/aws/aws-sdk-go-v2/credentials to
v1.20.17 ([#823](#823))
([27efc51](27efc51))
* **deps:** update module github.com/crewjam/saml to v0.6.3
([#807](#807))
([0f06336](0f06336))
* **deps:** update module github.com/wneessen/go-mail to v0.8.2
([#812](#812))
([3670206](3670206))
* **oncall:** record on-call override changes in the audit log
([#816](#816))
([4561f41](4561f41))
* serve robots.txt, indexable on solidping.io only
([#809](#809))
([3512833](3512833))
* **server:** refuse a pre-existing Windows service data folder others
control ([#817](#817))
([b1832b5](b1832b5))
* **vendorstatus:** drop datadog and atlassian from the catalog
([#814](#814))
([d3397c5](d3397c5))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant