-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathProgram.cs
More file actions
46 lines (36 loc) · 1.37 KB
/
Program.cs
File metadata and controls
46 lines (36 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System;
using System.Reflection;
using NServiceBus.Logging;
using ServiceControl.Audit.Infrastructure.Hosting;
using ServiceControl.Audit.Infrastructure.Hosting.Commands;
using ServiceControl.Audit.Infrastructure.Settings;
using ServiceControl.Configuration;
using ServiceControl.Infrastructure;
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();
if (exitCode != 0)
{
return exitCode;
}
ExeConfiguration.PopulateAppSettings(Assembly.GetExecutingAssembly());
var arguments = new HostArguments(args);
if (arguments.Help)
{
arguments.PrintUsage();
return 0;
}
var loggingSettings = new LoggingSettings(Settings.SettingsRootNamespace);
LoggingConfigurator.ConfigureLogging(loggingSettings);
var settings = new Settings(loggingSettings: loggingSettings);
await new CommandRunner(arguments.Command).Execute(arguments, settings);
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();
}