简体   繁体   English

使用 Topshelf 时服务没有及时响应启动或控制请求

[英]The service did not respond to the start or control request in a timely fashion when using Topshelf

I am trying to create a top-shelf service that depends on input from the command line.我正在尝试创建一个依赖于命令行输入的顶级服务。 But when using the configuration of the command line argument the service can't "start in a timely fashion".但是当使用命令行参数的配置时,服务不能“及时启动”。

My configuration of the service:我的服务配置:

If I remove the configuration of the language setting and hard code the value, the service starts just fine... Any ideas?如果我删除语言设置的配置并对值进行硬编码,服务启动就好了......有什么想法吗?

HostFactory.Run(conf =>
{
CultureInfo language = null; 

conf.AddCommandLineDefinition("language", lang => { language = new CultureInfo(lang); });
conf.ApplyCommandLine();
var countryCode = new RegionInfo(language.Name).TwoLetterISORegionName.ToUpper();
conf.SetDescription("{0} Order Broker".FormatWith(countryCode));
conf.SetDisplayName("{0} Order Broker".FormatWith(countryCode));
conf.SetServiceName("{0}OrderBroker".FormatWith(countryCode));

conf.StartAutomatically();
conf.RunAsLocalSystem();
conf.Service<IOrderService>(svc =>
{
   svc.ConstructUsing(name => Creator.Current.Create<IOrderService>());
   svc.WhenStarted(service => service.Start(language));
   svc.WhenStopped(service => service.Stop());
});
});

Here's the stacktrace:这是堆栈跟踪:

System.ComponentModel.Win32Exception: The service did not respond to the start
or control request in a timely fashion --- End of inner exception stack trace ---
at System.ServiceProcess.ServiceController.Start(String[] args)
at System.ServiceProcess.ServiceController.Start()
at Topshelf.Runtime.Windows.WindowsHostEnvironment.StartService(String serviceName)
at Topshelf.Hosts.StartHost.Run()

So the problem here is that language isn't provided when it starts as a service.所以这里的问题是当它作为服务启动时没有提供语言。 You'd need to edit the image-path for the service to include that command line parameter.您需要编辑服务的图像路径以包含该命令行参数。 I think you're much better off reading that from the app.config.我认为您最好从 app.config 中阅读它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误1053:服务未及时响应启动或控制请求 - Error 1053: the service did not respond to the start or control request in a timely fashion 错误 1053 服务没有及时响应启动或控制请求 - Error 1053 the service did not respond to the start or control request in a timely fashion 错误 1053:安装并运行 WCF 服务时,服务未及时响应启动或控制请求 - Error 1053: The service did not respond to the start or control request in a timely fashion, when intalled and ran a WCF service Windows服务无法启动&#39;错误1053:服务未及时响应启动或控制请求&#39; - Windows Service won't start 'Error 1053: The service did not respond to the start or control request in timely fashion' 本地无法启动topshelf服务:服务没有及时响应 - Can't start topshelf service locally: The service did not respond in a timely fashion 启动服务:“错误1053:服务未及时响应启动或控制请求” - Starting a service: “Error 1053: The service did not respond to the start or control request in a timely fashion” 安装Windows服务时出错 - 服务未及时响应启动或控制请求 - Error installing Windows service — The service did not respond to the start or control request in a timely fashion C#错误1053,服务未及时响应启动或控制请求 - C# Error 1053 the service did not respond to the start or control request in a timely fashion 发生错误1053,服务未及时响应启动或控制请求 - Im getting Error 1053 the service did not respond to the start or control request in a timely fashion 错误 1053:服务没有使用 FileSystemWatcher 及时响应启动或控制请求 - Error 1053:The service did not respond to start or control request in timely fashion with FileSystemWatcher
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM