3
注意不回:我没有做类似的事情,以Topshelf installer requires me to press enter twice - why?Topshelf:install命令在成功安装服务
服务类(有趣的部分):
public class ServiceCore
{
public ServiceCore(ServiceRuntimeConfiguration serviceRuntimeConfiguration)
{
_runningTasks = new List<Task>();
}
public bool Start(HostControl hostControl)
{
_hostControl = hostControl;
_messageProcessor.Start(); // Starts a System.Threading.Tasks.Task
StartListener(); // starts a System.Threading.Tasks.Task
return true;
}
}
的Program.cs:
Host host = HostFactory.New(configurator =>
{
configurator.UseNLog();
// Configure core service
configurator.Service<ServiceCore>(svc =>
{
svc.ConstructUsing(theService => new ServiceCore(_serviceRuntimeConfiguration));
svc.WhenStarted((svc, hostControl) => svc.Start(hostControl));
svc.WhenStopped((svc, hostControl) => svc.Stop(hostControl));
});
// Configure recovery params
configurator.EnableServiceRecovery(recoveryConfigurator =>
{
recoveryConfigurator.RestartService(0);
recoveryConfigurator.OnCrashOnly();
recoveryConfigurator.SetResetPeriod(1);
});
// Execute HostConfigurator
host.Run();
}
的问题
当我这样做:
MyService.exe install --manual --localsystem
服务安装罚款,但该命令不会返回:
运行事务处理安装。
开始安装的安装阶段。安装服务 NotificationEngine.Main ... Service NotificationEngine.Main已成功安装 。
安装阶段成功完成,提交阶段开始时为 。
提交阶段已成功完成。
交易安装已完成。
^C(我必须按CTRL + C)
我应该怎么install命令来完成,然后返回呢?
注意同样的行为是可观察的,如果我跑的帮助(即帮助的显示,但命令不返回):
MyService.exe help
感谢您的精心解答。我会检查并回复。 – dotnetguy