Skip to content
Merged
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
47 changes: 28 additions & 19 deletions src/ServiceControl.Audit/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,40 @@
using ServiceControl.Configuration;
using ServiceControl.Infrastructure;

AppDomain.CurrentDomain.UnhandledException += (s, e) => LogManager.GetLogger(typeof(Program)).Error("Unhandled exception was caught.", e.ExceptionObject as Exception);
try
{
AppDomain.CurrentDomain.UnhandledException += (s, e) => LogManager.GetLogger(typeof(Program)).Error("Unhandled exception was caught.", e.ExceptionObject as Exception);

// Hack: See https://github.com/Particular/ServiceControl/issues/4392
var exitCode = await IntegratedSetup.Run();
// Hack: See https://github.com/Particular/ServiceControl/issues/4392
var exitCode = await IntegratedSetup.Run();

if (exitCode != 0)
{
return exitCode;
}
if (exitCode != 0)
{
return exitCode;
}

ExeConfiguration.PopulateAppSettings(Assembly.GetExecutingAssembly());
ExeConfiguration.PopulateAppSettings(Assembly.GetExecutingAssembly());

var arguments = new HostArguments(args);
var arguments = new HostArguments(args);

if (arguments.Help)
{
arguments.PrintUsage();
return 0;
}
if (arguments.Help)
{
arguments.PrintUsage();
return 0;
}

var loggingSettings = new LoggingSettings(Settings.SettingsRootNamespace);
LoggingConfigurator.ConfigureLogging(loggingSettings);
var loggingSettings = new LoggingSettings(Settings.SettingsRootNamespace);
LoggingConfigurator.ConfigureLogging(loggingSettings);

var settings = new Settings(loggingSettings: loggingSettings);
var settings = new Settings(loggingSettings: loggingSettings);

await new CommandRunner(arguments.Command).Execute(arguments, settings);
await new CommandRunner(arguments.Command).Execute(arguments, settings);

return 0;
return 0;
}
finally
{
// The following log statement is meant to leave a trail in the logs to determine if the process was killed
NLog.LogManager.GetCurrentClassLogger().Info("Shutdown complete");
NLog.LogManager.Shutdown();
}
37 changes: 23 additions & 14 deletions src/ServiceControl.Monitoring/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,34 @@
using ServiceControl.Infrastructure;
using ServiceControl.Monitoring;

AppDomain.CurrentDomain.UnhandledException += (s, e) => LogManager.GetLogger(typeof(Program)).Error("Unhandled exception was caught.", e.ExceptionObject as Exception);
try
{
AppDomain.CurrentDomain.UnhandledException += (s, e) => LogManager.GetLogger(typeof(Program)).Error("Unhandled exception was caught.", e.ExceptionObject as Exception);

// Hack: See https://github.com/Particular/ServiceControl/issues/4392
var exitCode = await IntegratedSetup.Run();
// Hack: See https://github.com/Particular/ServiceControl/issues/4392
var exitCode = await IntegratedSetup.Run();

if (exitCode != 0)
{
return exitCode;
}
if (exitCode != 0)
{
return exitCode;
}

ExeConfiguration.PopulateAppSettings(Assembly.GetExecutingAssembly());
ExeConfiguration.PopulateAppSettings(Assembly.GetExecutingAssembly());

var arguments = new HostArguments(args);
var arguments = new HostArguments(args);

var loggingSettings = new LoggingSettings(Settings.SettingsRootNamespace);
LoggingConfigurator.ConfigureLogging(loggingSettings);
var loggingSettings = new LoggingSettings(Settings.SettingsRootNamespace);
LoggingConfigurator.ConfigureLogging(loggingSettings);

var settings = new Settings(loggingSettings: loggingSettings);
var settings = new Settings(loggingSettings: loggingSettings);

await new CommandRunner(arguments.Command).Execute(arguments, settings);
await new CommandRunner(arguments.Command).Execute(arguments, settings);

return 0;
return 0;
}
finally
{
// The following log statement is meant to leave a trail in the logs to determine if the process was killed
NLog.LogManager.GetCurrentClassLogger().Info("Shutdown complete");
NLog.LogManager.Shutdown();
}
2 changes: 2 additions & 0 deletions src/ServiceControl.RavenDB/EmbeddedDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@ public void Dispose()
EmbeddedServer.Instance.ServerProcessExited -= OnServerProcessExited;

shutdownTokenSource.Cancel();
Logger.Debug("Disposing RavenDB server");
EmbeddedServer.Instance.Dispose();
Logger.Debug("Dispose RavenDB server");
shutdownTokenSource.Dispose();
applicationStoppingRegistration.Dispose();

Expand Down
47 changes: 28 additions & 19 deletions src/ServiceControl/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,40 @@
using ServiceControl.Hosting.Commands;
using ServiceControl.Infrastructure;

AppDomain.CurrentDomain.UnhandledException += (s, e) => LogManager.GetLogger(typeof(Program)).Error("Unhandled exception was caught.", e.ExceptionObject as Exception);
try
{
AppDomain.CurrentDomain.UnhandledException += (s, e) => LogManager.GetLogger(typeof(Program)).Error("Unhandled exception was caught.", e.ExceptionObject as Exception);

// Hack: See https://github.com/Particular/ServiceControl/issues/4392
var exitCode = await IntegratedSetup.Run();
// Hack: See https://github.com/Particular/ServiceControl/issues/4392
var exitCode = await IntegratedSetup.Run();

if (exitCode != 0)
{
return exitCode;
}
if (exitCode != 0)
{
return exitCode;
}

ExeConfiguration.PopulateAppSettings(Assembly.GetExecutingAssembly());
ExeConfiguration.PopulateAppSettings(Assembly.GetExecutingAssembly());

var arguments = new HostArguments(args);
var arguments = new HostArguments(args);

if (arguments.Help)
{
arguments.PrintUsage();
return 0;
}
if (arguments.Help)
{
arguments.PrintUsage();
return 0;
}

var loggingSettings = new LoggingSettings(Settings.SettingsRootNamespace);
LoggingConfigurator.ConfigureLogging(loggingSettings);
var loggingSettings = new LoggingSettings(Settings.SettingsRootNamespace);
LoggingConfigurator.ConfigureLogging(loggingSettings);

var settings = new Settings(loggingSettings: loggingSettings);
var settings = new Settings(loggingSettings: loggingSettings);

await new CommandRunner(arguments.Command).Execute(arguments, settings);
await new CommandRunner(arguments.Command).Execute(arguments, settings);

return 0;
return 0;
}
finally
{
// The following log statement is meant to leave a trail in the logs to determine if the process was killed
NLog.LogManager.GetCurrentClassLogger().Info("Shutdown complete");
NLog.LogManager.Shutdown();
}