I have a Windows Service created using the TopShelf library. When attempting to start the service, it gives me an error:
Windows could not start the HPS.MyService.Service service on Local Computer
Error 1053: The service did not respond to the start of control request in a timely fashion.
This error happens immediately on startup, there is no 30 second delay.
The TopShelf code for my service looks like this:
public static void Main()
{
HostFactory.Run(x =>
{
x.Service<TopshelfHangfireService>();
x.EnableServiceRecovery(r => r.RestartService(TimeSpan.FromSeconds(30)));
x.SetServiceName("HPS.MyService");
x.StartAutomaticallyDelayed();
});
}
I've validated that I can run this service directly from a console window by invoking the executable using the same account that the service is supposed to run as.
Why am I getting this error - how can I get my service to successfully start?