-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathProgram.cs
More file actions
43 lines (34 loc) · 1.27 KB
/
Program.cs
File metadata and controls
43 lines (34 loc) · 1.27 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
using System;
using System.Reflection;
using NServiceBus.Logging;
using ServiceControl.Configuration;
using ServiceControl.Infrastructure;
using ServiceControl.Monitoring;
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);
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;
}
catch (Exception ex)
{
NLog.LogManager.GetCurrentClassLogger().Fatal(ex, "Unrecoverable error");
throw;
}
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();
}