Skip to content

Commit 11aaf72

Browse files
Introduce a setting to control the primary instance shutdown timeout
1 parent ba4fb02 commit 11aaf72

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/ServiceControl/HostApplicationBuilderExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public static void AddServiceControl(this IHostApplicationBuilder hostBuilder, S
5151
var transportCustomization = TransportFactory.Create(transportSettings);
5252
transportCustomization.AddTransportForPrimary(services, transportSettings);
5353

54-
services.Configure<HostOptions>(options => options.ShutdownTimeout = TimeSpan.FromSeconds(30));
54+
services.Configure<HostOptions>(options => options.ShutdownTimeout = settings.ShutdownTimeout);
5555
services.AddSingleton<IDomainEvents, DomainEvents>();
5656

5757
services.AddSingleton<MessageStreamerHub>();

src/ServiceControl/Infrastructure/Settings/Settings.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public Settings(
6565
TimeToRestartErrorIngestionAfterFailure = GetTimeToRestartErrorIngestionAfterFailure();
6666
DisableExternalIntegrationsPublishing = SettingsReader.Read(SettingsRootNamespace, "DisableExternalIntegrationsPublishing", false);
6767
TrackInstancesInitialValue = SettingsReader.Read(SettingsRootNamespace, "TrackInstancesInitialValue", true);
68+
ShutdownTimeout = SettingsReader.Read(SettingsRootNamespace, "ShutdownTimeout", ShutdownTimeout);
6869
AssemblyLoadContextResolver = static assemblyPath => new PluginAssemblyLoadContext(assemblyPath);
6970
}
7071

@@ -180,6 +181,11 @@ public TimeSpan HeartbeatGracePeriod
180181

181182
public bool DisableHealthChecks { get; set; }
182183

184+
// Windows services allow a maximum of 125 seconds when stopping a service.
185+
// When shutting down or restarting the OS we have no control over the
186+
// shutdown timeout
187+
public TimeSpan ShutdownTimeout { get; set; } = TimeSpan.FromMinutes(2);
188+
183189
public string GetConnectionString()
184190
{
185191
var settingsValue = SettingsReader.Read<string>(SettingsRootNamespace, "ConnectionString");

0 commit comments

Comments
 (0)