Fixed: CPU locking at a 100% in certain instances. (#2258) (Fixes #2218)

pull/2/head
Mike 7 years ago committed by Leonardo Galli
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 @@ namespace NzbDrone.Console
{
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 @@ namespace NzbDrone.Console
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 NLog;
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 @@ namespace Radarr.Host
}
_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.EnvironmentInfo;
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 @@ namespace Radarr.Host
{
startCallback(_container);
}
else
{
SpinToExit(appMode);
@ -69,8 +67,7 @@ namespace Radarr.Host
EnsureSingleInstance(applicationModes == ApplicationModes.Service, startupContext);
}
DbFactory.RegisterDatabase(_container);
_container.Resolve<Router>().Route(applicationModes);
}

Loading…
Cancel
Save