You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Readarr/NzbDrone/CentralDispatch.cs

68 lines
2.4 KiB

using Autofac;
using NLog;
using Nancy.Bootstrapper;
using NzbDrone.Api;
using NzbDrone.Common;
using NzbDrone.Core.Instrumentation;
using NzbDrone.Providers;
namespace NzbDrone
{
public static class CentralDispatch
{
private static IContainer _container;
private static readonly Logger Logger = LogManager.GetLogger("Host.CentralDispatch");
static CentralDispatch()
{
var builder = new ContainerBuilder();
BindKernel(builder);
_container = builder.Build();
InitilizeApp();
}
public static IContainer Container
{
get
{
return _container;
}
}
private static void BindKernel(ContainerBuilder builder)
{
builder.RegisterAssemblyTypes(typeof(DiskProvider).Assembly).SingleInstance();
builder.RegisterType<Router>();
builder.RegisterModule<LogInjectionModule>();
builder.RegisterType<NancyBootstrapper>().As<INancyBootstrapper>().SingleInstance();
builder.RegisterType<ApplicationServer>().SingleInstance();
builder.RegisterType<ConfigFileProvider>().SingleInstance();
builder.RegisterType<ConsoleProvider>().SingleInstance();
builder.RegisterType<EnvironmentProvider>().SingleInstance();
builder.RegisterType<HostController>().SingleInstance();
builder.RegisterType<MonitoringProvider>().SingleInstance();
builder.RegisterType<ProcessProvider>().SingleInstance();
builder.RegisterType<ServiceProvider>().SingleInstance();
builder.RegisterType<HttpProvider>().SingleInstance();
}
private static void InitilizeApp()
{
var environmentProvider = _container.Resolve<EnvironmentProvider>();
ReportingService.RestProvider = _container.Resolve<RestProvider>();
ReportingService.SetupExceptronDriver();
LogConfiguration.RegisterRollingFileLogger(environmentProvider.GetLogFileName(), LogLevel.Info);
LogConfiguration.RegisterConsoleLogger(LogLevel.Debug);
LogConfiguration.RegisterUdpLogger();
LogConfiguration.RegisterRemote();
LogConfiguration.Reload();
Logger.Info("Start-up Path:'{0}'", environmentProvider.ApplicationPath);
}
}
}