Topshelf超时问题 [英] Topshelf timeout issue

查看:1535
本文介绍了Topshelf超时问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用Topshelf托管服务。在开始服务之前,我们做的数据库调用加载大量的数据。正因为如此,在启动服务,我们得到以下错误:

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

我们使用的是下面的code以启动该服务:

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");
            });

如果我尝试使用Visual Studio推出的服务,服务的正常运行。但是,当服务是通过topshelf主持,我得到超时错误。

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.

我也尝试过使用 hostControl.RequestAdditionalTime(TimeSpan.FromSeconds(300))       但即使在添加额外的超时时间,我不能够解决问题。

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.

请提供您的建议。

感谢您

推荐答案

什么<一href="http://msdn.microsoft.com/en-us/library/system.serviceprocess.servicebase.requestadditionaltime.aspx"相对=nofollow称号=为RequestAdditionalTime文件>为 RequestAdditionalTime 文件没有状态是,你只能问一个最大的60或120秒。否则,忽略你的要求。它出色的文档没有在那里,我很清楚:(如果你发现它记录了一些的地方,请让我知道。

What the documentation for 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 documents no where that I'm aware of :( If you find it documented some where, please let me know.

这篇关于Topshelf超时问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆