mirror of https://github.com/Radarr/Radarr
IISExpress is now attached to NZBDrone.exe earlier, which means it should almost have a garanteed termination as soon as the host is killed.
Console logging starts earlier in the app. Moved Default profiles to QualityProvider.
This commit is contained in:
parent
ad89618f58
commit
8686eb5d32
|
@ -54,11 +54,11 @@ namespace NzbDrone.Core
|
|||
{
|
||||
BindKernel();
|
||||
|
||||
LogConfiguration.Setup();
|
||||
LogConfiguration.StartDbLogging();
|
||||
|
||||
Migrations.Run(Connection.MainConnectionString, true);
|
||||
|
||||
SetupDefaultQualityProfiles(_kernel.Get<IRepository>()); //Setup the default QualityProfiles on start-up
|
||||
_kernel.Get<QualityProvider>().SetupDefaultProfiles();
|
||||
|
||||
BindIndexers();
|
||||
BindJobs();
|
||||
|
@ -141,11 +141,11 @@ namespace NzbDrone.Core
|
|||
{
|
||||
try
|
||||
{
|
||||
Logger.Debug("Attaching to parent process for automatic termination.");
|
||||
var pc = new PerformanceCounter("Process", "Creating Process ID",
|
||||
Process.GetCurrentProcess().ProcessName);
|
||||
var pid = (int)pc.NextValue();
|
||||
var hostProcess = Process.GetProcessById(pid);
|
||||
var pid = Convert.ToInt32(Environment.GetEnvironmentVariable("NZBDRONE_PID"));
|
||||
|
||||
Logger.Debug("Attaching to parent process ({0}) for automatic termination.", pid);
|
||||
|
||||
var hostProcess = Process.GetProcessById(Convert.ToInt32(pid));
|
||||
|
||||
hostProcess.EnableRaisingEvents = true;
|
||||
hostProcess.Exited += (delegate
|
||||
|
@ -154,7 +154,7 @@ namespace NzbDrone.Core
|
|||
ShutDown();
|
||||
});
|
||||
|
||||
Logger.Debug("Successfully Attached to host. Process ID: {0}", pid);
|
||||
Logger.Debug("Successfully Attached to host. Process [{0}]", hostProcess.ProcessName);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -167,55 +167,5 @@ namespace NzbDrone.Core
|
|||
Logger.Info("Shutting down application.");
|
||||
Process.GetCurrentProcess().Kill();
|
||||
}
|
||||
|
||||
private static void SetupDefaultQualityProfiles(IRepository repository)
|
||||
{
|
||||
var sd = new QualityProfile
|
||||
{
|
||||
Name = "SD",
|
||||
Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD },
|
||||
Cutoff = QualityTypes.SDTV
|
||||
};
|
||||
|
||||
var hd = new QualityProfile
|
||||
{
|
||||
Name = "HD",
|
||||
Allowed =
|
||||
new List<QualityTypes> { QualityTypes.HDTV, QualityTypes.WEBDL, QualityTypes.Bluray720p },
|
||||
Cutoff = QualityTypes.HDTV
|
||||
};
|
||||
|
||||
//Add or Update SD
|
||||
Logger.Debug(String.Format("Checking for default QualityProfile: {0}", sd.Name));
|
||||
var sdDb = repository.Single<QualityProfile>(i => i.Name == sd.Name);
|
||||
if (sdDb == null)
|
||||
{
|
||||
Logger.Debug(String.Format("Adding new default QualityProfile: {0}", sd.Name));
|
||||
repository.Add(sd);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
Logger.Debug(String.Format("Updating default QualityProfile: {0}", sd.Name));
|
||||
sd.QualityProfileId = sdDb.QualityProfileId;
|
||||
repository.Update(sd);
|
||||
}
|
||||
|
||||
//Add or Update HD
|
||||
Logger.Debug(String.Format("Checking for default QualityProfile: {0}", hd.Name));
|
||||
var hdDb = repository.Single<QualityProfile>(i => i.Name == hd.Name);
|
||||
if (hdDb == null)
|
||||
{
|
||||
Logger.Debug(String.Format("Adding new default QualityProfile: {0}", hd.Name));
|
||||
repository.Add(hd);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
Logger.Debug(String.Format("Updating default QualityProfile: {0}", hd.Name));
|
||||
hd.QualityProfileId = hdDb.QualityProfileId;
|
||||
repository.Update(hd);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using Ninject;
|
||||
using Ninject.Activation;
|
||||
using NLog;
|
||||
using NLog.Config;
|
||||
|
||||
|
@ -17,12 +18,13 @@ namespace NzbDrone.Core.Instrumentation
|
|||
|
||||
LogManager.Configuration = new XmlLoggingConfiguration(Path.Combine(CentralDispatch.AppPath, "log.config"),
|
||||
false);
|
||||
LogManager.ConfigurationReloaded += ((s, e) => BindCustomLoggers());
|
||||
BindCustomLoggers();
|
||||
|
||||
LogManager.ConfigurationReloaded += ((s, e) => StartDbLogging());
|
||||
}
|
||||
|
||||
private static void BindCustomLoggers()
|
||||
public static void StartDbLogging()
|
||||
{
|
||||
|
||||
#if Release
|
||||
var exTarget = new ExceptioneerTarget();
|
||||
LogManager.Configuration.AddTarget("Exceptioneer", exTarget);
|
||||
|
@ -30,7 +32,7 @@ namespace NzbDrone.Core.Instrumentation
|
|||
#endif
|
||||
var sonicTarget = CentralDispatch.NinjectKernel.Get<SubsonicTarget>();
|
||||
LogManager.Configuration.AddTarget("DbLogger", sonicTarget);
|
||||
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", NLog.LogLevel.Info, sonicTarget));
|
||||
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Info, sonicTarget));
|
||||
|
||||
LogManager.Configuration.Reload();
|
||||
}
|
||||
|
|
|
@ -53,5 +53,39 @@ namespace NzbDrone.Core.Providers
|
|||
{
|
||||
return _repository.Single<QualityProfile>(q => q.QualityProfileId == profileId);
|
||||
}
|
||||
|
||||
public virtual void SetupDefaultProfiles()
|
||||
{
|
||||
Logger.Info("Setting up default quality profiles");
|
||||
|
||||
var profiles = GetAllProfiles();
|
||||
|
||||
var sd = new QualityProfile { Name = "SD", Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }, Cutoff = QualityTypes.SDTV };
|
||||
|
||||
var hd = new QualityProfile
|
||||
{
|
||||
Name = "HD",
|
||||
Allowed = new List<QualityTypes> { QualityTypes.HDTV, QualityTypes.WEBDL, QualityTypes.Bluray720p },
|
||||
Cutoff = QualityTypes.HDTV
|
||||
};
|
||||
|
||||
//Add or Update SD
|
||||
Logger.Debug(String.Format("Checking for default QualityProfile: {0}", sd.Name));
|
||||
var sdDb = profiles.Where(p => p.Name == sd.Name).FirstOrDefault();
|
||||
if (sdDb == null)
|
||||
{
|
||||
Logger.Debug(String.Format("Adding new default QualityProfile: {0}", sd.Name));
|
||||
Add(sd);
|
||||
}
|
||||
|
||||
//Add or Update HD
|
||||
Logger.Debug(String.Format("Checking for default QualityProfile: {0}", hd.Name));
|
||||
var hdDb = profiles.Where(p => p.Name == hd.Name).FirstOrDefault();
|
||||
if (hdDb == null)
|
||||
{
|
||||
Logger.Debug(String.Format("Adding new default QualityProfile: {0}", hd.Name));
|
||||
Add(hd);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -36,9 +36,6 @@ namespace NzbDrone.Web
|
|||
{
|
||||
base.OnApplicationStarted();
|
||||
|
||||
Logger.Info("NZBDrone Starting up.");
|
||||
CentralDispatch.DedicateToHost();
|
||||
|
||||
RegisterRoutes(RouteTable.Routes);
|
||||
//base.OnApplicationStarted();
|
||||
AreaRegistration.RegisterAllAreas();
|
||||
|
@ -48,6 +45,10 @@ namespace NzbDrone.Web
|
|||
|
||||
protected override IKernel CreateKernel()
|
||||
{
|
||||
LogConfiguration.Setup();
|
||||
Logger.Info("NZBDrone Starting up.");
|
||||
CentralDispatch.DedicateToHost();
|
||||
|
||||
var kernel = CentralDispatch.NinjectKernel;
|
||||
|
||||
// kernel.Bind<IRepository>().ToConstant(kernel.Get<IRepository>("LogDb"));
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
<rules>
|
||||
|
||||
<logger name="IIS*" minlevel="Trace" writeTo="consoleTarget"/>
|
||||
<logger name="NzbDrone.Web.MvcApplication" minlevel="Trace" writeTo="consoleTarget"/>
|
||||
<logger name="NzbDrone.Core.CentralDispatch" minlevel="Trace" writeTo="consoleTarget"/>
|
||||
<logger name="Application" minlevel="Trace" writeTo="consoleTarget"/>
|
||||
<logger name="*" minlevel="Trace" writeTo="udpTarget"/>
|
||||
<logger name="*" minlevel="Off" writeTo="xmlFile">
|
||||
|
|
|
@ -49,7 +49,8 @@ namespace NzbDrone
|
|||
IISProcess.ErrorDataReceived += (OnErrorDataReceived);
|
||||
|
||||
//Set Variables for the config file.
|
||||
Environment.SetEnvironmentVariable("NZBDRONE_PATH", Config.ProjectRoot);
|
||||
IISProcess.StartInfo.EnvironmentVariables.Add("NZBDRONE_PATH", Config.ProjectRoot);
|
||||
IISProcess.StartInfo.EnvironmentVariables.Add("NZBDRONE_PID", Process.GetCurrentProcess().Id.ToString());
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -148,6 +149,12 @@ namespace NzbDrone
|
|||
e.Data.StartsWith("Request ended:") || e.Data == ("IncrementMessages called"))
|
||||
return;
|
||||
|
||||
if (e.Data.Contains(" NzbDrone."))
|
||||
{
|
||||
Console.WriteLine(e.Data);
|
||||
return;
|
||||
}
|
||||
|
||||
IISLogger.Trace(e.Data);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue