You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Lidarr/NzbDrone/Program.cs

93 lines
2.4 KiB

14 years ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Threading;
using Exceptioneer.WindowsFormsClient;
14 years ago
using NLog;
using NLog.Config;
using NLog.Targets;
14 years ago
namespace NzbDrone
14 years ago
{
14 years ago
static class Program
14 years ago
{
14 years ago
private static readonly Logger Logger = LogManager.GetLogger("Application");
static void Main()
{
Logger.Info(Process.GetCurrentProcess().Id);
14 years ago
try
{
Thread.CurrentThread.Name = "Host";
14 years ago
AppDomain.CurrentDomain.UnhandledException += ((s, e) => AppDomainException(e));
AppDomain.CurrentDomain.ProcessExit += ProgramExited;
AppDomain.CurrentDomain.DomainUnload += ProgramExited;
System.Diagnostics.Process.GetCurrentProcess().Exited += ProgramExited;
14 years ago
Config.ConfigureNlog();
14 years ago
Logger.Info("Starting NZBDrone. Start-up Path:'{0}'", Config.ProjectRoot);
14 years ago
IISController.KillOrphaned();
IISController.StartIIS();
14 years ago
System.Diagnostics.Process.Start(IISController.AppUrl);
14 years ago
#if DEBUG
//Manually Attach debugger to IISExpress
if (Debugger.IsAttached)
{
try
{
ProcessAttacher.Attach();
}
catch (Exception e)
{
Logger.Warn("Unable to attach to debugger", e);
}
}
#endif
14 years ago
}
catch (Exception e)
{
AppDomainException(e);
}
Console.Write("Press Enter At Any Time To Exit...");
14 years ago
Console.ReadLine();
IISController.StopIIS();
14 years ago
}
private static void AppDomainException(object excepion)
{
Console.WriteLine("EPIC FAIL: {0}", excepion);
Logger.Fatal("EPIC FAIL: {0}", excepion);
new Client
14 years ago
{
ApiKey = "43BBF60A-EB2A-4C1C-B09E-422ADF637265",
ApplicationName = "NZBDrone",
CurrentException = excepion as Exception
}.Submit();
14 years ago
IISController.StopIIS();
14 years ago
}
14 years ago
static void ProgramExited(object sender, EventArgs e)
14 years ago
{
IISController.StopIIS();
14 years ago
}
14 years ago
}
}
14 years ago