2013-01-03 04:09:13 +03:00
|
|
|
using Autofac;
|
|
|
|
using NLog;
|
2013-02-19 04:13:42 +03:00
|
|
|
using Nancy.Bootstrapper;
|
|
|
|
using NzbDrone.Api;
|
2011-10-23 08:26:43 +03:00
|
|
|
using NzbDrone.Common;
|
2013-02-19 04:13:42 +03:00
|
|
|
using NzbDrone.Core.Instrumentation;
|
2011-10-11 10:11:05 +03:00
|
|
|
using NzbDrone.Providers;
|
|
|
|
|
|
|
|
namespace NzbDrone
|
|
|
|
{
|
|
|
|
public static class CentralDispatch
|
|
|
|
{
|
2013-01-03 04:09:13 +03:00
|
|
|
private static IContainer _container;
|
2011-10-12 05:24:43 +03:00
|
|
|
private static readonly Logger Logger = LogManager.GetLogger("Host.CentralDispatch");
|
2011-10-11 10:11:05 +03:00
|
|
|
|
|
|
|
static CentralDispatch()
|
|
|
|
{
|
2013-01-03 04:09:13 +03:00
|
|
|
var builder = new ContainerBuilder();
|
|
|
|
BindKernel(builder);
|
|
|
|
_container = builder.Build();
|
2011-10-13 05:24:30 +03:00
|
|
|
InitilizeApp();
|
2011-10-11 10:11:05 +03:00
|
|
|
}
|
|
|
|
|
2013-01-03 04:09:13 +03:00
|
|
|
public static IContainer Container
|
2011-10-11 10:11:05 +03:00
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2013-01-03 04:09:13 +03:00
|
|
|
return _container;
|
2011-10-11 10:11:05 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-03 04:09:13 +03:00
|
|
|
private static void BindKernel(ContainerBuilder builder)
|
2011-10-11 10:11:05 +03:00
|
|
|
{
|
2013-01-03 04:09:13 +03:00
|
|
|
builder.RegisterAssemblyTypes(typeof(DiskProvider).Assembly).SingleInstance();
|
2013-01-03 06:04:42 +03:00
|
|
|
builder.RegisterType<Router>();
|
2011-10-13 05:24:30 +03:00
|
|
|
|
2013-02-19 04:13:42 +03:00
|
|
|
builder.RegisterModule<LogInjectionModule>();
|
|
|
|
|
|
|
|
|
|
|
|
builder.RegisterType<NancyBootstrapper>().As<INancyBootstrapper>().SingleInstance();
|
2013-01-03 04:09:13 +03:00
|
|
|
builder.RegisterType<ApplicationServer>().SingleInstance();
|
|
|
|
builder.RegisterType<ConfigFileProvider>().SingleInstance();
|
|
|
|
builder.RegisterType<ConsoleProvider>().SingleInstance();
|
|
|
|
builder.RegisterType<EnvironmentProvider>().SingleInstance();
|
2013-02-19 04:13:42 +03:00
|
|
|
builder.RegisterType<HostController>().SingleInstance();
|
2013-01-03 04:09:13 +03:00
|
|
|
builder.RegisterType<MonitoringProvider>().SingleInstance();
|
|
|
|
builder.RegisterType<ProcessProvider>().SingleInstance();
|
|
|
|
builder.RegisterType<ServiceProvider>().SingleInstance();
|
|
|
|
builder.RegisterType<HttpProvider>().SingleInstance();
|
2011-10-11 10:11:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
private static void InitilizeApp()
|
|
|
|
{
|
2013-01-03 04:09:13 +03:00
|
|
|
var environmentProvider = _container.Resolve<EnvironmentProvider>();
|
2012-03-02 04:57:36 +03:00
|
|
|
|
2013-01-03 04:09:13 +03:00
|
|
|
ReportingService.RestProvider = _container.Resolve<RestProvider>();
|
2012-04-30 04:24:24 +03:00
|
|
|
ReportingService.SetupExceptronDriver();
|
2012-01-23 05:24:16 +03:00
|
|
|
|
2012-03-07 05:59:43 +03:00
|
|
|
LogConfiguration.RegisterRollingFileLogger(environmentProvider.GetLogFileName(), LogLevel.Info);
|
2011-10-24 08:54:09 +03:00
|
|
|
LogConfiguration.RegisterConsoleLogger(LogLevel.Debug);
|
|
|
|
LogConfiguration.RegisterUdpLogger();
|
2012-02-05 09:34:36 +03:00
|
|
|
LogConfiguration.RegisterRemote();
|
2011-11-13 10:27:16 +03:00
|
|
|
LogConfiguration.Reload();
|
2012-03-07 05:59:43 +03:00
|
|
|
Logger.Info("Start-up Path:'{0}'", environmentProvider.ApplicationPath);
|
2011-10-11 10:11:05 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|