diff --git a/src/ServiceControl.Audit/App.config b/src/ServiceControl.Audit/App.config
index 83610fa6ee..57d1cfc374 100644
--- a/src/ServiceControl.Audit/App.config
+++ b/src/ServiceControl.Audit/App.config
@@ -8,6 +8,8 @@ These settings are only here so that we can debug ServiceControl while developin
+
+
@@ -20,8 +22,8 @@ These settings are only here so that we can debug ServiceControl while developin
-
-
+
+
diff --git a/src/ServiceControl.Audit/HostApplicationBuilderExtensions.cs b/src/ServiceControl.Audit/HostApplicationBuilderExtensions.cs
index 8968565a50..923bbeae4b 100644
--- a/src/ServiceControl.Audit/HostApplicationBuilderExtensions.cs
+++ b/src/ServiceControl.Audit/HostApplicationBuilderExtensions.cs
@@ -42,7 +42,7 @@ public static void AddServiceControlAudit(this IHostApplicationBuilder builder,
var transportCustomization = TransportFactory.Create(transportSettings);
transportCustomization.AddTransportForAudit(services, transportSettings);
- services.Configure(options => options.ShutdownTimeout = TimeSpan.FromSeconds(30));
+ services.Configure(options => options.ShutdownTimeout = settings.ShutdownTimeout);
services.AddSingleton(settings);
services.AddSingleton();
diff --git a/src/ServiceControl.Audit/Infrastructure/Settings/Settings.cs b/src/ServiceControl.Audit/Infrastructure/Settings/Settings.cs
index 183b695555..b8865298c9 100644
--- a/src/ServiceControl.Audit/Infrastructure/Settings/Settings.cs
+++ b/src/ServiceControl.Audit/Infrastructure/Settings/Settings.cs
@@ -51,6 +51,8 @@ public Settings(string transportType = null, string persisterType = null, Loggin
EnableFullTextSearchOnBodies = SettingsReader.Read(SettingsRootNamespace, "EnableFullTextSearchOnBodies", true);
AssemblyLoadContextResolver = static assemblyPath => new PluginAssemblyLoadContext(assemblyPath);
+ ShutdownTimeout = SettingsReader.Read(SettingsRootNamespace, "ShutdownTimeout", ShutdownTimeout);
+ Environment.SetEnvironmentVariable("ShutdownTimeout", ShutdownTimeout.ToString());
}
void LoadAuditQueueInformation()
@@ -151,6 +153,8 @@ public int MaxBodySizeToStore
public bool EnableFullTextSearchOnBodies { get; set; }
+ public TimeSpan ShutdownTimeout { get; set; } = TimeSpan.FromMinutes(5);
+
public TransportSettings ToTransportSettings()
{
var transportSettings = new TransportSettings
diff --git a/src/ServiceControl.RavenDB/EmbeddedDatabase.cs b/src/ServiceControl.RavenDB/EmbeddedDatabase.cs
index 9e4b711b0b..9c1b40eeca 100644
--- a/src/ServiceControl.RavenDB/EmbeddedDatabase.cs
+++ b/src/ServiceControl.RavenDB/EmbeddedDatabase.cs
@@ -15,6 +15,7 @@ namespace ServiceControl.RavenDB
using Raven.Client.Documents.Conventions;
using Raven.Client.ServerWide.Operations;
using Raven.Embedded;
+ using Sparrow.Logging;
public sealed class EmbeddedDatabase : IDisposable
{
@@ -52,9 +53,24 @@ public static EmbeddedDatabase Start(EmbeddedDatabaseConfiguration databaseConfi
var nugetPackagesPath = Path.Combine(databaseConfiguration.DbPath, "Packages", "NuGet");
+ LoggingSource.Instance.SetupLogMode(
+ (LogMode)255,
+ Path.Combine(databaseConfiguration.LogPath, "client"),
+ TimeSpan.FromDays(7),
+ 1024 * 1024 * 10,
+ false
+ );
+
+ LoggingSource.Instance.EnableConsoleLogging();
+
+ var gracefulShutdownTimeout = TimeSpan.Parse(Environment.GetEnvironmentVariable("ShutdownTimeout")!);
+ // Must be less to ensure teardown of child process completes
+ gracefulShutdownTimeout -= TimeSpan.FromSeconds(5);
+
Logger.InfoFormat("Loading RavenDB license from {0}", licenseFileNameAndServerDirectory.LicenseFileName);
var serverOptions = new ServerOptions
{
+ GracefulShutdownTimeout = gracefulShutdownTimeout,
CommandLineArgs =
[
$"--Logs.Mode={databaseConfiguration.LogsMode}",
diff --git a/src/ServiceControl/HostApplicationBuilderExtensions.cs b/src/ServiceControl/HostApplicationBuilderExtensions.cs
index 0c365fecbc..a1774d4b30 100644
--- a/src/ServiceControl/HostApplicationBuilderExtensions.cs
+++ b/src/ServiceControl/HostApplicationBuilderExtensions.cs
@@ -51,7 +51,7 @@ public static void AddServiceControl(this IHostApplicationBuilder hostBuilder, S
var transportCustomization = TransportFactory.Create(transportSettings);
transportCustomization.AddTransportForPrimary(services, transportSettings);
- services.Configure(options => options.ShutdownTimeout = TimeSpan.FromSeconds(30));
+ services.Configure(options => options.ShutdownTimeout = settings.ShutdownTimeout);
services.AddSingleton();
services.AddSingleton();
diff --git a/src/ServiceControl/Infrastructure/Settings/Settings.cs b/src/ServiceControl/Infrastructure/Settings/Settings.cs
index 04b7a232bb..2dff350f9f 100644
--- a/src/ServiceControl/Infrastructure/Settings/Settings.cs
+++ b/src/ServiceControl/Infrastructure/Settings/Settings.cs
@@ -66,6 +66,8 @@ public Settings(
DisableExternalIntegrationsPublishing = SettingsReader.Read(SettingsRootNamespace, "DisableExternalIntegrationsPublishing", false);
TrackInstancesInitialValue = SettingsReader.Read(SettingsRootNamespace, "TrackInstancesInitialValue", true);
AssemblyLoadContextResolver = static assemblyPath => new PluginAssemblyLoadContext(assemblyPath);
+ ShutdownTimeout = SettingsReader.Read(SettingsRootNamespace, "ShutdownTimeout", ShutdownTimeout);
+ Environment.SetEnvironmentVariable("ShutdownTimeout", ShutdownTimeout.ToString());
}
[JsonIgnore]
@@ -180,6 +182,8 @@ public TimeSpan HeartbeatGracePeriod
public bool DisableHealthChecks { get; set; }
+ public TimeSpan ShutdownTimeout { get; set; } = TimeSpan.FromMinutes(5);
+
public string GetConnectionString()
{
var settingsValue = SettingsReader.Read(SettingsRootNamespace, "ConnectionString");