JulianusIV
JulianusIV
Explore posts from servers
CC#
Created by JulianusIV on 2/7/2023 in #help
✅ 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:
Consoel.CancelKeyPress += (sender, e) =>
{
//do something and wait for api requests
app.Lifetime.StopApplication();
}
Consoel.CancelKeyPress += (sender, e) =>
{
//do something and wait for api requests
app.Lifetime.StopApplication();
}
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 docker
17 replies
CC#
Created by JulianusIV on 2/7/2023 in #help
✅ Blocking ASP.NET Core Shutdown fully
but if nothing like that works now ill just add a little admin panel and add a stop feature that handles the whole unsubscribe and then shuts down the api
17 replies
CC#
Created by JulianusIV on 2/7/2023 in #help
✅ 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
CC#
Created by JulianusIV on 2/7/2023 in #help
✅ Blocking ASP.NET Core Shutdown fully
same as if you just send a ctrl + c
17 replies
CC#
Created by JulianusIV on 2/7/2023 in #help
✅ Blocking ASP.NET Core Shutdown fully
i know that docker still gives the container content time to shutdown gracefully
17 replies
CC#
Created by JulianusIV on 2/7/2023 in #help
✅ 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
CC#
Created by JulianusIV on 2/7/2023 in #help
✅ Blocking ASP.NET Core Shutdown fully
Ill take a look at that thank you
17 replies
CC#
Created by JulianusIV on 2/7/2023 in #help
✅ 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
CC#
Created by JulianusIV on 2/7/2023 in #help
✅ Blocking ASP.NET Core Shutdown fully
I need to unsubscribe a lease
17 replies
CC#
Created by JulianusIV on 2/7/2023 in #help
✅ Blocking ASP.NET Core Shutdown fully
Well uhh ill take that as a no
17 replies