JulianusIV
Explore posts from servers✅ Blocking ASP.NET Core Shutdown fully
Well ill just add something as an answer here then
For just running something in console blocking SIGINT with
Console.CancelKeyPress
like:
in your Main will work perfectly fine.
Docker however seems to be sending a SIGTERM on stop.
SIGTERM can be held up using AppDomain.CurrentDomain.ProcessExit
, however the api shutdown is already triggered at that point, which makes the api refuse any connections.
The easiest solution here, and what i will be doing, is probably to add the SIGINT handler for when it is ran in console, but also add a button in a management page to shut down the application, which waits for all requests to come in before calling app.Lifetime.StopApplication()
, for using it in docker17 replies
✅ Blocking ASP.NET Core Shutdown fully
and i had something like this in an earlier version (asp.net core 3.1), where using Lifetime.ApplicationStopped would work (as far as i remember), but since i updated to net7 it just refuses connection immediately
17 replies
✅ Blocking ASP.NET Core Shutdown fully
after reading through this i dont exactly know how i would use this to achieve what i want to do, since the api simple refuses the connection as soon as a ctrl + c (or a docker stop) is being sent to it, and even if i were to add filters id still need to be able to get a call into my Controller in order to properly be able to handle it, unless one of those filters is still being sent data during a shutdown, so i can just move my controller logic to a filter (which would probably pose a whole load of other issues with security and the such i imagine)
17 replies
✅ Blocking ASP.NET Core Shutdown fully
Basically
I start up the api, and it sends out requests, subscribing to a few topics
During a lease time i then get api requests back whenever that topic is updated
Unsubscribe and subscribe both require me me to respond with a challenge tho, which is why i still need the api up during shutdown
17 replies