|
|
@ -1,5 +1,6 @@
|
|
|
|
using System;
|
|
|
|
using System;
|
|
|
|
using System.Diagnostics;
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
|
|
using System.IO;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Linq;
|
|
|
|
using Ninject;
|
|
|
|
using Ninject;
|
|
|
|
using NLog;
|
|
|
|
using NLog;
|
|
|
@ -7,68 +8,58 @@ using NzbDrone.Common;
|
|
|
|
using NzbDrone.Core.Datastore;
|
|
|
|
using NzbDrone.Core.Datastore;
|
|
|
|
using NzbDrone.Core.Instrumentation;
|
|
|
|
using NzbDrone.Core.Instrumentation;
|
|
|
|
using NzbDrone.Core.Providers;
|
|
|
|
using NzbDrone.Core.Providers;
|
|
|
|
using NzbDrone.Core.Providers.Core;
|
|
|
|
|
|
|
|
using NzbDrone.Core.Providers.ExternalNotification;
|
|
|
|
using NzbDrone.Core.Providers.ExternalNotification;
|
|
|
|
using NzbDrone.Core.Providers.Indexer;
|
|
|
|
using NzbDrone.Core.Providers.Indexer;
|
|
|
|
using NzbDrone.Core.Providers.Jobs;
|
|
|
|
using NzbDrone.Core.Providers.Jobs;
|
|
|
|
using PetaPoco;
|
|
|
|
using PetaPoco;
|
|
|
|
using LogConfiguration = NzbDrone.Core.Instrumentation.LogConfiguration;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core
|
|
|
|
namespace NzbDrone.Core
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public class CentralDispatch
|
|
|
|
public class CentralDispatch
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private readonly Object KernelLock = new object();
|
|
|
|
|
|
|
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
|
|
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
|
|
|
|
|
|
|
|
|
|
|
public CentralDispatch()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
InitializeApp();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public StandardKernel Kernel { get; private set; }
|
|
|
|
public StandardKernel Kernel { get; private set; }
|
|
|
|
|
|
|
|
|
|
|
|
private void InitializeApp()
|
|
|
|
public CentralDispatch()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
BindKernel();
|
|
|
|
Logger.Debug("Initializing Kernel:");
|
|
|
|
|
|
|
|
Kernel = new StandardKernel();
|
|
|
|
|
|
|
|
|
|
|
|
Kernel.Get<LogConfiguration>().Setup();
|
|
|
|
InitDatabase();
|
|
|
|
|
|
|
|
|
|
|
|
var mainConnectionString = Kernel.Get<Connection>().MainConnectionString;
|
|
|
|
InitQuality();
|
|
|
|
|
|
|
|
InitExternalNotifications();
|
|
|
|
|
|
|
|
InitIndexers();
|
|
|
|
|
|
|
|
InitJobs();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MigrationsHelper.Run(mainConnectionString, true);
|
|
|
|
private void InitDatabase()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Logger.Info("Initializing Database...");
|
|
|
|
|
|
|
|
|
|
|
|
LogConfiguration.RegisterDatabaseLogger(Kernel.Get<DatabaseTarget>());
|
|
|
|
var appDataPath = new EnviromentProvider().GetAppDataPath();
|
|
|
|
LogConfiguration.Reload();
|
|
|
|
if (!Directory.Exists(appDataPath)) Directory.CreateDirectory(appDataPath);
|
|
|
|
|
|
|
|
|
|
|
|
Kernel.Get<QualityProvider>().SetupDefaultProfiles();
|
|
|
|
var connection = Kernel.Get<Connection>();
|
|
|
|
Kernel.Get<QualityTypeProvider>().SetupDefault();
|
|
|
|
Kernel.Bind<IDatabase>().ToMethod(c => connection.GetMainPetaPocoDb()).InTransientScope();
|
|
|
|
Kernel.Get<ConfigFileProvider>().CreateDefaultConfigFile();
|
|
|
|
Kernel.Bind<IDatabase>().ToMethod(c => connection.GetLogPetaPocoDb(false)).WhenInjectedInto<DatabaseTarget>().InSingletonScope();
|
|
|
|
|
|
|
|
Kernel.Bind<IDatabase>().ToMethod(c => connection.GetLogPetaPocoDb()).WhenInjectedInto<LogProvider>().InSingletonScope();
|
|
|
|
|
|
|
|
|
|
|
|
BindExternalNotifications();
|
|
|
|
Kernel.Get<DatabaseTarget>().Register();
|
|
|
|
BindIndexers();
|
|
|
|
LogConfiguration.Reload();
|
|
|
|
BindJobs();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void BindKernel()
|
|
|
|
private void InitQuality()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
lock (KernelLock)
|
|
|
|
Logger.Info("Initializing Quality...");
|
|
|
|
{
|
|
|
|
Kernel.Get<QualityProvider>().SetupDefaultProfiles();
|
|
|
|
Logger.Debug("Binding Ninject's Kernel");
|
|
|
|
Kernel.Get<QualityTypeProvider>().SetupDefault();
|
|
|
|
Kernel = new StandardKernel();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var connection = Kernel.Get<Connection>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Kernel.Bind<IDatabase>().ToMethod(c => connection.GetMainPetaPocoDb()).InTransientScope();
|
|
|
|
|
|
|
|
Kernel.Bind<IDatabase>().ToMethod(c => connection.GetLogPetaPocoDb(false)).WhenInjectedInto<DatabaseTarget>().InSingletonScope();
|
|
|
|
|
|
|
|
Kernel.Bind<IDatabase>().ToMethod(c => connection.GetLogPetaPocoDb()).WhenInjectedInto<LogProvider>().InSingletonScope();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Kernel.Bind<JobProvider>().ToSelf().InSingletonScope();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void BindIndexers()
|
|
|
|
private void InitIndexers()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
Logger.Info("Initializing Indexers...");
|
|
|
|
Kernel.Bind<IndexerBase>().To<NzbsOrg>();
|
|
|
|
Kernel.Bind<IndexerBase>().To<NzbsOrg>();
|
|
|
|
Kernel.Bind<IndexerBase>().To<NzbMatrix>();
|
|
|
|
Kernel.Bind<IndexerBase>().To<NzbMatrix>();
|
|
|
|
Kernel.Bind<IndexerBase>().To<NzbsRUs>();
|
|
|
|
Kernel.Bind<IndexerBase>().To<NzbsRUs>();
|
|
|
@ -79,8 +70,12 @@ namespace NzbDrone.Core
|
|
|
|
Kernel.Get<IndexerProvider>().InitializeIndexers(indexers.ToList());
|
|
|
|
Kernel.Get<IndexerProvider>().InitializeIndexers(indexers.ToList());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void BindJobs()
|
|
|
|
private void InitJobs()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
Logger.Info("Initializing Background Jobs...");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Kernel.Bind<JobProvider>().ToSelf().InSingletonScope();
|
|
|
|
|
|
|
|
|
|
|
|
Kernel.Bind<IJob>().To<RssSyncJob>().InSingletonScope();
|
|
|
|
Kernel.Bind<IJob>().To<RssSyncJob>().InSingletonScope();
|
|
|
|
Kernel.Bind<IJob>().To<ImportNewSeriesJob>().InSingletonScope();
|
|
|
|
Kernel.Bind<IJob>().To<ImportNewSeriesJob>().InSingletonScope();
|
|
|
|
Kernel.Bind<IJob>().To<UpdateInfoJob>().InSingletonScope();
|
|
|
|
Kernel.Bind<IJob>().To<UpdateInfoJob>().InSingletonScope();
|
|
|
@ -102,8 +97,9 @@ namespace NzbDrone.Core
|
|
|
|
Kernel.Get<WebTimer>().StartTimer(30);
|
|
|
|
Kernel.Get<WebTimer>().StartTimer(30);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void BindExternalNotifications()
|
|
|
|
private void InitExternalNotifications()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
Logger.Info("Initializing External Notifications...");
|
|
|
|
Kernel.Bind<ExternalNotificationBase>().To<Xbmc>();
|
|
|
|
Kernel.Bind<ExternalNotificationBase>().To<Xbmc>();
|
|
|
|
Kernel.Bind<ExternalNotificationBase>().To<Smtp>();
|
|
|
|
Kernel.Bind<ExternalNotificationBase>().To<Smtp>();
|
|
|
|
Kernel.Bind<ExternalNotificationBase>().To<Twitter>();
|
|
|
|
Kernel.Bind<ExternalNotificationBase>().To<Twitter>();
|
|
|
@ -114,9 +110,6 @@ namespace NzbDrone.Core
|
|
|
|
Kernel.Get<ExternalNotificationProvider>().InitializeNotifiers(notifiers.ToList());
|
|
|
|
Kernel.Get<ExternalNotificationProvider>().InitializeNotifiers(notifiers.ToList());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// Forces IISExpress process to exit with the host application
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
public void DedicateToHost()
|
|
|
|
public void DedicateToHost()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
try
|
|
|
@ -144,7 +137,7 @@ namespace NzbDrone.Core
|
|
|
|
|
|
|
|
|
|
|
|
private static void ShutDown()
|
|
|
|
private static void ShutDown()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Logger.Info("Shutting down application.");
|
|
|
|
Logger.Info("Shutting down application...");
|
|
|
|
WebTimer.Stop();
|
|
|
|
WebTimer.Stop();
|
|
|
|
Process.GetCurrentProcess().Kill();
|
|
|
|
Process.GetCurrentProcess().Kill();
|
|
|
|
}
|
|
|
|
}
|
|
|
|