feat(installer): add Stop/StartServiceStep sc.exe wrappers
This commit is contained in:
27
src/ClaudeDo.Installer/Steps/StartServiceStep.cs
Normal file
27
src/ClaudeDo.Installer/Steps/StartServiceStep.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using ClaudeDo.Installer.Core;
|
||||
|
||||
namespace ClaudeDo.Installer.Steps;
|
||||
|
||||
public sealed class StartServiceStep : IInstallStep
|
||||
{
|
||||
private const string ServiceName = StopServiceStep.ServiceName;
|
||||
|
||||
public string Name => "Start Worker Service";
|
||||
|
||||
public async Task<StepResult> ExecuteAsync(InstallContext ctx, IProgress<string> progress, CancellationToken ct)
|
||||
{
|
||||
progress.Report($"Starting {ServiceName}...");
|
||||
|
||||
var (exit, output) = await ProcessRunner.RunAsync("sc.exe", $"start {ServiceName}", null, progress, ct);
|
||||
if (exit == 0) return StepResult.Ok();
|
||||
|
||||
// Exit 1056 = already running — that's fine too.
|
||||
if (output.Contains("1056", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
progress.Report("Service was already running.");
|
||||
return StepResult.Ok();
|
||||
}
|
||||
|
||||
return StepResult.Fail($"sc.exe start failed with exit code {exit}");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user