我正在使用Topshelf创建一个Windows服务。此服务将尝试恢复前3个故障,但在那之后,它不再工作。
在主机上的服务中检查服务显示:
First Failure: Restart the Service
Second Failure: Restart the Service
Subsequent Failures: Restart the Service
Reset fail count after: 1 days
Restart service after: 2 minutes
服务恢复代码如下所示:
f.EnableServiceRecovery(r =>
{
r.RestartService(2);
r.RestartService(5);
r.RestartService(5);
r.OnCrashOnly();
r.SetResetPeriod(1);
});
在恢复失败后,检查事件日志会显示以下消息:
The MyService service terminated unexpectedly. It has done this 1 time(s). The following corrective action will be taken in 120000 milliseconds: Restart the service.
The MyService service terminated unexpectedly. It has done this 2 time(s). The following corrective action will be taken in 300000 milliseconds: Restart the service.
The MyService service terminated unexpectedly. It has done this 3 time(s). The following corrective action will be taken in 300000 milliseconds: Restart the service.
The MyService service terminated unexpectedly. It has done this 4 time(s).
从上面可以明显看出。第四次不会触发恢复。
这是Windows错误、Topshelf问题还是我的配置有问题?