依赖于RabbitMQ的Topshelf服务不会在重启时启动

JD.*_*JD. 7 c# windows-services rabbitmq easynetq

我有一个使用EasyNetQ和RabbitMQ的Windows服务.该服务通常从服务控制管理器启动.但是我偶尔看到重启时,服务不会从服务事件日志中的错误开始:

A timeout was reached (30000 milliseconds) 

The <serviceName> service failed to start due to the following error: 
The service did not respond to the start or control request in a timely fashion.
Run Code Online (Sandbox Code Playgroud)

我试过自动延迟服务,这没有帮助.

另外,我正在考虑设置恢复机制,这样如果它没有启动,它会在第一次/第二次和随后的故障时重新启动.不确定这是否有效.

所以我的问题是如何确定导致我的服务无法启动的依赖性是什么?

Leo*_*zes 0

为了确定导致错误的依赖项,您可以尝试在 TopShelf“OnException”(https://topshelf.readthedocs.io/en/latest/configuration/config_api.html#oneException)上附加一个处理程序并记录以下异常:导致了错误。