Skip to content

Commit

Permalink
Increase ShutdownTimeout from 5 sec to 30 sec
Browse files Browse the repository at this point in the history
  • Loading branch information
mburumaxwell committed Sep 20, 2023
1 parent 6849f19 commit 317cc72
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions server/Tingle.Dependabot/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@

var builder = WebApplication.CreateBuilder(args);

builder.Services.Configure<HostOptions>(options =>
{
/*
* The shutdown timer is extended to background tasks (mostly IHostedService) time to close down gracefully
* Andrew Lock explains it in 2 of his posts
*
* https://andrewlock.net/extending-the-shutdown-timeout-setting-to-ensure-graceful-ihostedservice-shutdown/
* https://andrewlock.net/deploying-asp-net-core-applications-to-kubernetes-part-11-avoiding-downtime-in-rolling-deployments-by-blocking-sigterm/
*
* The default is 5 seconds but in our case 30 seconds is sufficient and matches the Kubernetes default.
* This should be enough for the services running like the EventBus or incoming HTTP requests to complete processing.
*/
options.ShutdownTimeout = TimeSpan.FromSeconds(30);
});

builder.Services.AddApplicationInsightsTelemetry(builder.Configuration);

// Add DbContext
Expand Down

0 comments on commit 317cc72

Please sign in to comment.