DotNetCore.WindowsService
DotNetCore.WindowsService copied to clipboard
ConsoleHost shutdown timeout too short
When running as a console application, shutdown is only given 150ms to complete. I have a very simple application and all I'm doing in shutdown is starting an async stop of an aspnet core application and it takes about 170ms to complete.
The ServiceHost gives a 1000ms timeout here in this case. I would recommend minimally making the timeouts match in the ConsoleHost. Ideally, all of these timeouts would be configurable. I believe the win32 service api allows an application to request additional startup/shutdown time if these timeouts were to be made significantly larger.
Functionality added by https://github.com/PeterKottas/DotNetCore.WindowsService/releases/tag/v2.0.5. Timeout is now configurable. Thanks for raising this
Peter maybe I'm being dense, I don't see changes in 2.0.5 that address this issue.
Maybe we're talking about different timeouts then. I've modified the one that waits for change in service state and made it configurable. Is it not the one you were talking about?
In ConsoleServiceHost.cs, the method HandleCancelKeyPress only waits 150ms for the application to terminate after sending the stop signal. I don't have a way to get my application to respond to the event that quickly when running locally. This timeout is much shorter than the same timeout in the real service host.
Ah sure, the topshelf ripoff :) Ok I should be able to get that there over the weekend.
Fixed by https://github.com/PeterKottas/DotNetCore.WindowsService/releases/tag/v2.0.8
There is still a timeout of 150ms in ConsoleServiceHost / HandleCancelKeyPress at line 112. I have also an issue with this short time to shutdown the application or debug in the shutdown. Could all this timeouts be made configurable?
Yeah definitely. Feel free to create a PR to do this. I might end up doing it myself but it will take a few weeks at least.