Skip to content

Commit d14d671

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

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/ServiceControl.Audit/HostApplicationBuilderExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public static void AddServiceControlAudit(this IHostApplicationBuilder builder,
4545
var transportCustomization = TransportFactory.Create(transportSettings);
4646
transportCustomization.AddTransportForAudit(services, transportSettings);
4747

48-
services.Configure<HostOptions>(options => options.ShutdownTimeout = TimeSpan.FromSeconds(30));
48+
services.Configure<HostOptions>(options => options.ShutdownTimeout = settings.ShutdownTimeout);
4949

5050
services.AddSingleton(settings);
5151
services.AddSingleton<EndpointInstanceMonitoring>();

src/ServiceControl.Audit/Infrastructure/Settings/Settings.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public Settings(string transportType = null, string persisterType = null, Loggin
4949
ServiceControlQueueAddress = SettingsReader.Read<string>(SettingsRootNamespace, "ServiceControlQueueAddress");
5050
TimeToRestartAuditIngestionAfterFailure = GetTimeToRestartAuditIngestionAfterFailure();
5151
EnableFullTextSearchOnBodies = SettingsReader.Read(SettingsRootNamespace, "EnableFullTextSearchOnBodies", true);
52+
ShutdownTimeout = SettingsReader.Read(SettingsRootNamespace, "ShutdownTimeout", ShutdownTimeout);
5253

5354
AssemblyLoadContextResolver = static assemblyPath => new PluginAssemblyLoadContext(assemblyPath);
5455
}
@@ -152,6 +153,11 @@ public int MaxBodySizeToStore
152153

153154
public bool EnableFullTextSearchOnBodies { get; set; }
154155

156+
// Windows services allow a maximum of 125 seconds when stopping a service.
157+
// When shutting down or restarting the OS we have no control over the
158+
// shutdown timeout
159+
public TimeSpan ShutdownTimeout { get; set; } = TimeSpan.FromMinutes(2);
160+
155161
public TransportSettings ToTransportSettings()
156162
{
157163
var transportSettings = new TransportSettings

0 commit comments

Comments
 (0)