-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SIGTERM handling #5932
Comments
The last time I checked, the recommendation was to hook up the I wonder if the |
Ah, this comment clears up the confusion; https://github.com/dotnet/coreclr/issues/2688#issuecomment-394843595 |
According to the comment I linked:
So the documentation should be correct. |
Linked to wrong doc earlier, should have been WaitForShutdown that indicates it blocks for a ctrl-c or sigterm What I am seeing with a sigterm, is that the code after WaitForShutdown is not executed, the process is actually terminated, but a sigint/ctrl-c does execute these lines and seems to have a grace period for inflight requests. If I add a AppDomain.CurrentDomain.ProcessExit event handler as you indicated, then I could treat like a continuation I guess and do my cleanup there |
Yeah, I think there's a difference in how In the former case, if you set But in the latter case, it'll just wait for the event delegate to complete (which should still wait for in-flight requests to finish (I think it's 2 seconds?)), then shut down immediately. |
Doesn't wait to leave inflight requests complete with So it looks like I need to cater for this in the event handler as you said Surprises me as this is going to be something anyone running on docker or kubernetes is going to have to deal with, would prefer to do so in Program.main as we may have other hosts i.e. GenericHost's running, don't want to have use IApplicationLifetime |
|
FYI There are 2 options that I could see at this time b) Use k8s preStop lifecyle event Option a is the one I went with |
Closing this as no further action is planned here. |
Hi,
I'm seeing issues with handling sigterm on a linux system, seeing similar behaviour to 516 but on linux
Environment info
OS: ubuntu 16.04 64bit
dotnet --version is 2.1.300
As the docs indicate WaitForShutdown should handle sigterm, sigint and ctrl-c
Can see it handling sigint and ctrl-c as expected, but sigterm is not behaving as documented for me
Since sigterm is what docker will send to a container being stopped this is pretty important for graceful shutdowns with log entries
I create a standard webapi project with
dotnet new webapi
and altered the Program.cs as followsSo
ctlr-c
andkill -INT pid
are working as expected and the exiting log lines appearBut
kill pid
is just resulting in the process terminating with no exiting log lines, this I did not expect and is an issue with docker where I need it to handle a sigtermThanks in advance
Pat
The text was updated successfully, but these errors were encountered: