diff --git a/src/Runner.Listener/Configuration/NativeWindowsServiceHelper.cs b/src/Runner.Listener/Configuration/NativeWindowsServiceHelper.cs index 28dc257b4..76f07d1f0 100644 --- a/src/Runner.Listener/Configuration/NativeWindowsServiceHelper.cs +++ b/src/Runner.Listener/Configuration/NativeWindowsServiceHelper.cs @@ -678,6 +678,17 @@ namespace GitHub.Runner.Listener.Configuration if (service != null) { service.Start(); + + try + { + _term.WriteLine("Waiting for service to start..."); + service.WaitForStatus(ServiceControllerStatus.Running, TimeSpan.FromSeconds(60)); + } + catch (System.ServiceProcess.TimeoutException) + { + throw new InvalidOperationException($"Cannot start the service {serviceName} in a timely fashion."); + } + _term.WriteLine($"Service {serviceName} started successfully"); } else