PeterKottas / DotNetCore.WindowsService

Simple library that allows one to host dot net core application as windows services. Perfect solution to power micro-services architecture.
MIT License
568 stars 150 forks source link

ConsoleHost shutdown timeout too short #61

Open Tanhe opened 6 years ago

Tanhe commented 6 years ago

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.

PeterKottas commented 6 years ago

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

Tanhe commented 6 years ago

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

PeterKottas commented 6 years ago

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?

Tanhe commented 6 years ago

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.

PeterKottas commented 6 years ago

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

PeterKottas commented 6 years ago

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

knoxi commented 6 years ago

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?

PeterKottas commented 6 years ago

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.