Skip to content

Commit 9e37732

Browse files
authored
Verify that has Windows service started successfully (#236)
1 parent 6c70d53 commit 9e37732

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/Runner.Listener/Configuration/NativeWindowsServiceHelper.cs

+11
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,17 @@ public void StartService(string serviceName)
678678
if (service != null)
679679
{
680680
service.Start();
681+
682+
try
683+
{
684+
_term.WriteLine("Waiting for service to start...");
685+
service.WaitForStatus(ServiceControllerStatus.Running, TimeSpan.FromSeconds(60));
686+
}
687+
catch (System.ServiceProcess.TimeoutException)
688+
{
689+
throw new InvalidOperationException($"Cannot start the service {serviceName} in a timely fashion.");
690+
}
691+
681692
_term.WriteLine($"Service {serviceName} started successfully");
682693
}
683694
else

0 commit comments

Comments
 (0)