Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Topshelf timeout issue

We are using Topshelf to host a service. Before starting the service, we are making database call to load lot of data. Because of this, while starting the service, we are getting following error:

Start Service failed with return code '[7] ServiceRequestTimeout

We are using following code to start the service:

HostFactory.Run(x =>
            {
                x.Service<AppService>(s =>
                {
                    s.ConstructUsing(name => new AppService(s_resolver, baseAddress, resolver));
                    s.WhenStarted(svc => svc.Start());
                    s.WhenStopped(svc => svc.Stop());
                    s.WhenShutdown(svc => svc.Shutdown());
                });

                x.EnableShutdown();
                x.RunAsLocalService();
                x.StartAutomatically();
                x.SetDisplayName("Application Host");
                x.SetDescription("Application Host");
            });

If I try to launch the service using Visual Studio, service runs fine. But when the service is hosted through Topshelf, I am getting time out error.

I have also tried using hostControl.RequestAdditionalTime(TimeSpan.FromSeconds(300)) but even after adding additional timeout period, I am not able to resolve the issue. Please provide your suggestions.

like image 249
SharpCoder Avatar asked Oct 25 '13 12:10

SharpCoder


1 Answers

What the documentation for HostControl.RequestAdditionalTime fails to state is that you can only ask for a max of 60 or 120 seconds. Otherwise it ignores your request.

It's brilliantly documented absolutely no where that I'm aware of :( If you find it documented some where, please let me know.

like image 176
Travis Avatar answered Sep 22 '22 12:09

Travis