Service: harden for unattended running (auto-restart, findable logs, resume)
Local checkpoint - NOT for public release. A "what else does a service need" pass. - AUTO-RESTART ON CRASH: DoInstall now sets sc failure actions (restart 5s/10s/then 60s, reset daily). Without this a crashed service stays dead until reboot - fatal for an always-on streamer. - FINDABLE LOGS: --run-service redirects the service's data dir to the machine-wide ProgramData\RemSound\service location, so its log sits next to its profile instead of buried in the SYSTEM account's AppData. - POWER RESUME: the service handles OnPowerEvent and re-opens capture on wake (audio devices re-initialise after sleep; the device-change watcher usually catches it, but a resume doesn't always fire an endpoint change, so we re-open explicitly). - Start/stop already auto-log to the Windows Event Log via ServiceBase. Test: "Service registration args" now also checks the audio-service dependency and the auto-restart failure args. Gate 27/27. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
4f5265d8b0
commit
92ed477ddf
@@ -98,9 +98,17 @@ public static class ServiceControl
|
||||
if (rc != 0) return rc;
|
||||
// Best-effort description; failure here doesn't fail the install.
|
||||
RunSc($"description {ServiceName} \"{Description}\"");
|
||||
// Auto-restart on crash: without this a crashed service stays dead until reboot, which defeats
|
||||
// an always-on streamer. Restart 5s / 10s / then every 60s; reset the failure counter daily.
|
||||
RunSc(BuildFailureArgs());
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>The sc.exe "failure" args that make the service auto-restart on a crash. Pure, so a
|
||||
/// self-test can verify the format.</summary>
|
||||
internal static string BuildFailureArgs() =>
|
||||
$"failure {ServiceName} reset= 86400 actions= restart/5000/restart/10000/restart/60000";
|
||||
|
||||
/// <summary>Stops (if running) and deletes the service. Must be run elevated. Returns 0 on success or
|
||||
/// if it wasn't installed.</summary>
|
||||
public static int DoUninstall()
|
||||
|
||||
Reference in New Issue
Block a user