From 9e3773240177d08bd67797f01392edf8aa06f991 Mon Sep 17 00:00:00 2001 From: Julio Barba Date: Thu, 19 Dec 2019 14:34:26 -0500 Subject: [PATCH] Verify that has Windows service started successfully (#236) --- .../Configuration/NativeWindowsServiceHelper.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) 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