DotNetCore.WindowsService icon indicating copy to clipboard operation
DotNetCore.WindowsService copied to clipboard

ConsoleHost shutdown timeout too short

Open Tanhe opened this issue 7 years ago • 8 comments

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.

Tanhe avatar Dec 14 '17 15:12 Tanhe

Functionality added by https://github.com/PeterKottas/DotNetCore.WindowsService/releases/tag/v2.0.5. Timeout is now configurable. Thanks for raising this

PeterKottas avatar Dec 14 '17 15:12 PeterKottas

Peter maybe I'm being dense, I don't see changes in 2.0.5 that address this issue.

Tanhe avatar Dec 21 '17 22:12 Tanhe

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?

PeterKottas avatar Jan 05 '18 18:01 PeterKottas

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.

Tanhe avatar Jan 05 '18 19:01 Tanhe

Ah sure, the topshelf ripoff :) Ok I should be able to get that there over the weekend.

PeterKottas avatar Jan 05 '18 20:01 PeterKottas

Fixed by https://github.com/PeterKottas/DotNetCore.WindowsService/releases/tag/v2.0.8

PeterKottas avatar Jun 02 '18 12:06 PeterKottas

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?

knoxi avatar Aug 16 '18 11:08 knoxi

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.

PeterKottas avatar Aug 16 '18 13:08 PeterKottas