A refused start under the Windows service leaves an error entry in the Application event log #338

Merged
claude merged 2 commits from feature/336-windows-refusal-visibility into develop 2026-11-06 01:59:16 -05:00
Owner

Under the Windows service, a deliberate startup refusal (exit 78: the key-ring certificate, the JWT key, the storage registration, the relational migrator, the MongoDB guard, the pending storage switch) left no trace before this change: no console, nothing in the event log, and the service simply stopped.

  • A new StartupRefusalReporter is used by all six refusal handlers in Program.cs. It logs the critical line as before. When Ninlil runs as a Windows service and no host logger exists yet (the key-ring, JWT and storage-registration sites), it also writes one Error entry to the Application log under Ninlil.Web. The later sites pass the host logger, whose own EventLog provider records the line, so there is never a second entry. An event-log failure is logged and never throws.
  • README Windows section: where a refused start is reported and how to read it (Get-WinEvent). sc.exe query shows exit code 0 because the refusal happens before the service connects to the Service Control Manager; exit 78 appears in a console run.

Verified on Lofnheim (Windows 10.0.26200, NT SERVICE\Ninlil), with exe builds of 0f3e2dc5 and 11a18414:

  • Missing key-ring certificate: one Error entry naming the setting, with no password. Start-Service fails with "Cannot start service".
  • Database a newer version upgraded: the first build showed two entries. After the fix there is one entry, and Start-Service fails.

On Linux: build has 0 warnings, csharpier is clean, Web.Tests passes 2352 (without the Docker-only tests), and StartupRefusalProcessTests still shows exit 78.

Closes #336

🤖 Generated with Claude Code

https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK

Under the Windows service, a deliberate startup refusal (exit 78: the key-ring certificate, the JWT key, the storage registration, the relational migrator, the MongoDB guard, the pending storage switch) left no trace before this change: no console, nothing in the event log, and the service simply stopped. - A new `StartupRefusalReporter` is used by all six refusal handlers in `Program.cs`. It logs the critical line as before. When Ninlil runs as a Windows service and no host logger exists yet (the key-ring, JWT and storage-registration sites), it also writes one Error entry to the Application log under `Ninlil.Web`. The later sites pass the host logger, whose own EventLog provider records the line, so there is never a second entry. An event-log failure is logged and never throws. - README Windows section: where a refused start is reported and how to read it (`Get-WinEvent`). `sc.exe query` shows exit code 0 because the refusal happens before the service connects to the Service Control Manager; exit 78 appears in a console run. Verified on Lofnheim (Windows 10.0.26200, `NT SERVICE\Ninlil`), with exe builds of 0f3e2dc5 and 11a18414: - **Missing key-ring certificate:** one Error entry naming the setting, with no password. `Start-Service` fails with "Cannot start service". - **Database a newer version upgraded:** the first build showed two entries. After the fix there is one entry, and `Start-Service` fails. On Linux: build has 0 warnings, csharpier is clean, Web.Tests passes 2352 (without the Docker-only tests), and `StartupRefusalProcessTests` still shows exit 78. Closes #336 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK
Closes #336

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK
A refused start under the Windows service leaves exactly one error entry, not two
Some checks failed
Build / Pack and Push NuGet Packages (dns-core) (pull_request) Successful in 1m58s
Build / Pack and Push NuGet Packages (dns-server) (pull_request) Successful in 1m54s
Build / Build Binary (windows-amd64) (pull_request) Successful in 2m46s
Build / Build Binary (macos-arm64) (pull_request) Successful in 34s
Build / Build Binary (macos-amd64) (pull_request) Successful in 30s
Build / Build Binary (linux-amd64) (pull_request) Successful in 32s
Build / Build Binary (linux-arm64) (pull_request) Successful in 34s
Build / Build and Push Image (pull_request) Successful in -2m37s
Build / Smoke Test the Windows Binary (pull_request) Successful in 17s
Build / Build Arch Linux Packages (pull_request) Successful in 23s
Build / Build and Test Deb and RPM Packages (pull_request) Successful in 2m10s
Build / Publish Release (pull_request) Successful in 5s
Build / Pipeline (pull_request) Successful in 0s
Build / Test .NET (push) Failing after 50m48s
Build / Stage Draft Release (push) Has been skipped
Build / Pack and Push NuGet Packages (dhcp) (push) Has been skipped
Build / Pack and Push NuGet Packages (dns-server) (push) Has been skipped
Build / Pack and Push NuGet Packages (common) (push) Has been skipped
Build / Build Binary (linux-arm64) (push) Has been skipped
Build / Build Binary (linux-amd64) (push) Has been skipped
Build / Pack and Push NuGet Packages (dns-core) (push) Has been skipped
Build / Build Binary (macos-arm64) (push) Has been skipped
Build / Build Binary (macos-amd64) (push) Has been skipped
Build / Build Binary (windows-amd64) (push) Has been skipped
Build / Build and Test Deb and RPM Packages (push) Has been skipped
Build / Build and Push Image (push) Has been skipped
Build / Build Arch Linux Packages (push) Has been skipped
Build / Smoke Test the Windows Binary (push) Has been skipped
Build / Pipeline (push) Failing after 0s
Build / Publish Release (push) Has been skipped
11a18414ff
Refs #336

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK
claude merged commit b9dd930f8e into develop 2026-11-06 01:59:16 -05:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
lantea-one/ninlil!338
No description provided.