-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Handling SIGTERM in asp.net core middleware in docker container #11391
Comments
Graceful shutdown already works out of the box with ASP.NET Core so there’s no need to re-implement it. |
Is this the reason, why I cannot get any of these events while debbuging? |
Maybe? I’m not sure about that but I know you can delete your code because it’s handled |
Hi again, I've created a simple demo here, which is not working, unfortunately. I am going to work on that further in some free time and update this thread :) |
Tested in a 2 .net core application: In both cases, I wasn't able to catch this while debugging, while running container in interactive mode shows log messages on all events. The last thing that I want to test is IApplicationLifetime on docker container interactive. I suspect that it will be working, but again, I won't be able to debug. Regards |
I can confirm that all of the solutions are working on |
@meanin great! |
Hi All,
is it possible at all? I created simple asp.net core application here. The application is running in linux docker container. Now, I am trying to implement graceful shutdown, with waiting for current request completion. I tried many different ways, starts from
AppDomain.CurrentDomain.ProcessExit += OnProcessExit
, going troughConsole.CancelKeyPress += ConsoleOnCancelKeyPress
and finished onAssemblyLoadContext.Default.Unloading += OnUnloading
. I tried to place it inside a middleware as well as on top of program.cs. I am stoping docker with command below:docker stop -t 30 containerId
Docker documentation says, that this should cause SIGTERM on a first try, wait given time and raise SIGKILL.
I already saw issues:
aspnet/Hosting#870
https://github.com/aspnet/Hosting/issues/1527
https://github.com/dotnet/coreclr/issues/2688
https://github.com/dotnet/coreclr/issues/8565
Any guess?
The text was updated successfully, but these errors were encountered: