mirror of
https://github.com/Radarr/Radarr.git
synced 2024-10-05 15:47:20 +02:00
This commit is contained in:
parent
5dc2df3d49
commit
e4a3e63c44
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Net.Sockets;
|
||||
using NLog;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
@ -11,6 +11,13 @@ public static class ConsoleApp
|
||||
{
|
||||
private static readonly Logger Logger = NzbDroneLogger.GetLogger(typeof(ConsoleApp));
|
||||
|
||||
private enum ExitCodes : int
|
||||
{
|
||||
Normal = 0,
|
||||
UnknownFailure = 1,
|
||||
RecoverableFailure = 2
|
||||
}
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
try
|
||||
@ -19,30 +26,41 @@ public static void Main(string[] args)
|
||||
NzbDroneLogger.Register(startupArgs, false, true);
|
||||
Bootstrap.Start(startupArgs, new ConsoleAlerts());
|
||||
}
|
||||
catch (SocketException exception)
|
||||
catch (SocketException e)
|
||||
{
|
||||
System.Console.WriteLine("");
|
||||
System.Console.WriteLine("");
|
||||
Logger.Fatal(exception.Message + ". This can happen if another instance of Radarr is already running another application is using the same port (default: 7878) or the user has insufficient permissions");
|
||||
System.Console.WriteLine("Press enter to exit...");
|
||||
System.Console.ReadLine();
|
||||
Environment.Exit(1);
|
||||
Logger.Fatal(e.Message + ". This can happen if another instance of Radarr is already running another application is using the same port (default: 7878) or the user has insufficient permissions");
|
||||
Exit(ExitCodes.RecoverableFailure);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.Console.WriteLine("");
|
||||
System.Console.WriteLine("");
|
||||
Logger.Fatal(e, "EPIC FAIL!");
|
||||
System.Console.WriteLine("Press enter to exit...");
|
||||
System.Console.ReadLine();
|
||||
Environment.Exit(1);
|
||||
Exit(ExitCodes.UnknownFailure);
|
||||
}
|
||||
|
||||
Logger.Info("Exiting main.");
|
||||
|
||||
//Need this to terminate on mono (thanks nlog)
|
||||
LogManager.Configuration = null;
|
||||
Environment.Exit(0);
|
||||
Exit(ExitCodes.Normal);
|
||||
}
|
||||
|
||||
private static void Exit(ExitCodes exitCode)
|
||||
{
|
||||
LogManager.Shutdown();
|
||||
|
||||
if (exitCode != ExitCodes.Normal)
|
||||
{
|
||||
System.Console.WriteLine("Press enter to exit...");
|
||||
|
||||
System.Threading.Thread.Sleep(1000);
|
||||
|
||||
// Please note that ReadLine silently succeeds if there is no console, KeyAvailable does not.
|
||||
System.Console.ReadLine();
|
||||
}
|
||||
|
||||
Environment.Exit((int)exitCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
using NzbDrone.Common.Composition;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Lifecycle;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
using Radarr.Host.Owin;
|
||||
@ -56,6 +57,7 @@ public void Start()
|
||||
}
|
||||
|
||||
_runtimeInfo.IsRunning = true;
|
||||
DbFactory.RegisterDatabase(_container);
|
||||
_hostController.StartServer();
|
||||
|
||||
if (!_startupContext.Flags.Contains(StartupContext.NO_BROWSER)
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using NLog;
|
||||
@ -7,7 +7,6 @@
|
||||
using NzbDrone.Common.Instrumentation;
|
||||
using NzbDrone.Common.Processes;
|
||||
using NzbDrone.Common.Security;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Instrumentation;
|
||||
|
||||
namespace Radarr.Host
|
||||
@ -43,7 +42,6 @@ public static void Start(StartupContext startupContext, IUserAlert userAlert, Ac
|
||||
{
|
||||
startCallback(_container);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
SpinToExit(appMode);
|
||||
@ -69,8 +67,7 @@ private static void Start(ApplicationModes applicationModes, StartupContext star
|
||||
|
||||
EnsureSingleInstance(applicationModes == ApplicationModes.Service, startupContext);
|
||||
}
|
||||
|
||||
DbFactory.RegisterDatabase(_container);
|
||||
|
||||
_container.Resolve<Router>().Route(applicationModes);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user