Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/ServiceControl.Audit/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ These settings are only here so that we can debug ServiceControl while developin
<add key="ServiceControl.Audit/ServiceControlQueueAddress" value="Particular.ServiceControl" />
<add key="ServiceControl.Audit/HostName" value="localhost" />
<add key="ServiceControl.Audit/DatabaseMaintenancePort" value="44445" />
<add key="ServiceControl.Audit/LogPath" value="/tmp/sc_audit/logs" />
<add key="ServiceControl.Audit/DBPath" value="/tmp/sc_audit/db" />

<!-- DEVS - Pick a transport to run Auditing instance on -->
<add key="ServiceControl.Audit/TransportType" value="LearningTransport" />
Expand All @@ -20,8 +22,8 @@ These settings are only here so that we can debug ServiceControl while developin
<!--<add key="ServiceControl.Audit/TransportType" value="SQLServer" />-->

<!-- DEVS - Pick a persistence to run Auditing instance on. -->
<add key="ServiceControl.Audit/PersistenceType" value="InMemory" />
<!--<add key="ServiceControl.Audit/PersistenceType" value="RavenDB" />-->
<!-- <add key="ServiceControl.Audit/PersistenceType" value="InMemory" /> -->
<add key="ServiceControl.Audit/PersistenceType" value="RavenDB" />
</appSettings>
<connectionStrings>
<!-- DEVS - Pick a transport connection string to match chosen transport above -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static void AddServiceControlAudit(this IHostApplicationBuilder builder,
var transportCustomization = TransportFactory.Create(transportSettings);
transportCustomization.AddTransportForAudit(services, transportSettings);

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

services.AddSingleton(settings);
services.AddSingleton<EndpointInstanceMonitoring>();
Expand Down
4 changes: 4 additions & 0 deletions src/ServiceControl.Audit/Infrastructure/Settings/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions src/ServiceControl.RavenDB/EmbeddedDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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}",
Expand Down
2 changes: 1 addition & 1 deletion src/ServiceControl/HostApplicationBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static void AddServiceControl(this IHostApplicationBuilder hostBuilder, S
var transportCustomization = TransportFactory.Create(transportSettings);
transportCustomization.AddTransportForPrimary(services, transportSettings);

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

services.AddSingleton<MessageStreamerHub>();
Expand Down
4 changes: 4 additions & 0 deletions src/ServiceControl/Infrastructure/Settings/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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<string>(SettingsRootNamespace, "ConnectionString");
Expand Down