fix(restart): skip systemctl probe on Windows; route through OS-aware strategy#102
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
… strategy
POST /api/server/restart always tried `sudo -n systemctl restart
7daystodie.service` first and waited up to 5 seconds for it to either
succeed or fail before falling back to in-game shutdown. On Linux
this is correct (systemd Restart=always bounces the service). On
Windows it is wrong twice over:
- `systemctl` does not exist on Windows, so the probe always fails
fast and wastes ~5s plus logs a misleading "systemctl restart
failed or not available..." warning on every restart click.
- On a live Windows prod box today this entire code path was the
trigger for a cascading crash: the fallback in-game shutdown ran
concurrent with a stuck main-thread operation and snowballed into
a stack overflow. Beyond cosmetic, it was risk-shaped.
Fix: introduce Core/OsRestartStrategy.cs as a small pure helper.
`OsRestartStrategy.Decide(bool isWindows)` returns one of two kinds:
- SystemctlThenInGameShutdown (Linux): unchanged behavior — try
systemctl, fall back to in-game shutdown for systemd
Restart=always.
- InGameShutdownOnly (Windows): skip the systemctl probe entirely,
go straight to in-game shutdown. NSSM (the standard Windows
service supervisor for 7DTD) ships with `AppExit Restart` as its
default and auto-bounces the service when the game process
exits, so this is the correct supervised-restart path on Windows.
Windows path logs INFO ("Windows install detected; using in-game
shutdown + service-supervisor restart") instead of WARNING — the
operator should see we *chose* this path, not that we fell back into
it.
`OsRestartStrategy.DecideForCurrentHost()` reads the host platform via
the existing `PlatformHelper.IsWindows` (Environment.OSVersion.Platform,
works under both .NET Framework and Mono). The pure `Decide(bool)`
overload keeps the decision testable without touching the real OS
check — covered by two NUnit tests in
KitsuneCommand.Tests/Core/OsRestartStrategyTests.cs.
`krestart` console command was checked and does not need the same
treatment — it goes through GracefulRestartFeature.TriggerNow, which
is pure in-game shutdown and never shells out.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
01e4417 to
863be23
Compare
5 tasks
AdaInTheLab
added a commit
that referenced
this pull request
Jun 4, 2026
Cuts v2.8.2. Three fixes from the live Windows prod box plus the timezone field on the Server Restart panel grows up into a host- resolvable dropdown. No new pages, no schema changes — patch release per docs/RELEASES.md conventions. What lands: - #101 fix(websocket): stop LogCallbackEvent broadcast recursion in shutdown. ThreadStatic re-entrancy guard + suppressFailureLogging fallback to Console.Error so a failed log-broadcast can't fire a fresh LogCallbackEvent and recurse to stack overflow. - #102 fix(restart): skip systemctl probe on Windows; route through OS-aware strategy. New Core/OsRestartStrategy.cs picks per OS; Windows goes straight to in-game shutdown + NSSM AppExit Restart bounce, no more wasted 5s probe or misleading warning. - #103 feat(restart): host-resolvable timezone dropdown + heal-on-read. LoadPersistedSettings heals an unresolvable TZ ID to TimeZoneInfo .Local and persists. New GET /api/server/timezones endpoint feeds a PrimeVue Select in Settings → Server Restart, replacing the free- text input that admins kept filling with strings the host couldn't parse. Version bumps: - src/KitsuneCommand/ModInfo.xml: 2.8.1 → 2.8.2 - frontend/package.json: 2.7.4 → 2.8.2 (reconciles prior drift — frontend version was stuck at 2.7.4 since v2.8.0) - CHANGELOG.md: promote [Unreleased] → [2.8.2] - 2026-06-04 Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
POST /api/server/restartalways triedsudo -n systemctl restart 7daystodie.servicefirst and waited up to 5 seconds for it to either succeed or fail before falling back to in-game shutdown. On Linux this is correct (systemdRestart=alwaysbounces the service). On Windows it is wrong twice over:systemctldoes not exist on Windows, so the probe always fails fast and wastes ~5s plus logs a misleading"systemctl restart failed or not available..."warning on every restart click.On a live Windows prod box today this entire code path was the trigger for a cascading crash: the fallback in-game shutdown ran concurrent with a stuck main-thread operation and snowballed into a stack overflow. Beyond cosmetic, it was risk-shaped.
Fix
New
Core/OsRestartStrategy.csas a small pure helper.OsRestartStrategy.Decide(bool isWindows)returns one of two kinds:SystemctlThenInGameShutdown(Linux): unchanged behavior — trysystemctl, fall back to in-game shutdown forsystemd Restart=always.InGameShutdownOnly(Windows): skip thesystemctlprobe entirely, go straight to in-game shutdown. NSSM (the standard Windows service supervisor for 7DTD) ships withAppExit Restartas its default and auto-bounces the service when the game process exits, so this is the correct supervised-restart path on Windows.Windows path logs INFO (
"Windows install detected; using in-game shutdown + service-supervisor restart") instead of WARNING — the operator should see we chose this path, not that we fell back into it.OsRestartStrategy.DecideForCurrentHost()reads the host platform via the existingPlatformHelper.IsWindows(Environment.OSVersion.Platform, works under both .NET Framework and Mono). The pureDecide(bool)overload keeps the decision testable without touching the real OS check — covered by 2 NUnit tests inKitsuneCommand.Tests/Core/OsRestartStrategyTests.cs.krestartconsole command was checked and does not need the same treatment — it goes throughGracefulRestartFeature.TriggerNow, which is pure in-game shutdown and never shells out.Test plan
OsRestartStrategyTestspasssystemctlwarning + service auto-restarts via NSSMsystemctlfirst (unchanged behavior)🤖 Generated with Claude Code