Register Types in Updater

pull/4/head
Mark McDowall 12 years ago
parent be2a5ea754
commit 05aed27923

@ -3,10 +3,8 @@ using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection;
using Autofac; using Autofac;
using Autofac.Core; using Autofac.Core;
using DeskMetrics;
using NLog; using NLog;
using NzbDrone.Common; using NzbDrone.Common;
using NzbDrone.Core.Instrumentation; using NzbDrone.Core.Instrumentation;
@ -19,10 +17,7 @@ using NzbDrone.Core.Providers.Metadata;
using NzbDrone.Core.Repository; using NzbDrone.Core.Repository;
using PetaPoco; using PetaPoco;
using SignalR; using SignalR;
using SignalR.Hosting.AspNet;
using SignalR.Infrastructure;
using Connection = NzbDrone.Core.Datastore.Connection; using Connection = NzbDrone.Core.Datastore.Connection;
using Xbmc = NzbDrone.Core.Providers.ExternalNotification.Xbmc;
namespace NzbDrone.Core namespace NzbDrone.Core
{ {

@ -12,7 +12,7 @@ namespace NzbDrone.Update
{ {
private readonly UpdateProvider _updateProvider; private readonly UpdateProvider _updateProvider;
private readonly ProcessProvider _processProvider; private readonly ProcessProvider _processProvider;
private static IContainer _kernel; private static IContainer _container;
private static readonly Logger logger = LogManager.GetCurrentClassLogger(); private static readonly Logger logger = LogManager.GetCurrentClassLogger();
@ -27,11 +27,13 @@ namespace NzbDrone.Update
try try
{ {
Console.WriteLine("Starting NzbDrone Update Client"); Console.WriteLine("Starting NzbDrone Update Client");
_kernel = new ContainerBuilder().Build(); var builder = new ContainerBuilder();
builder.RegisterAssemblyTypes(typeof(UpdateProvider).Assembly).SingleInstance();
_container = builder.Build();
InitLoggers(); InitLoggers();
logger.Info("Updating NzbDrone to version {0}", _kernel.Resolve<EnvironmentProvider>().Version); logger.Info("Updating NzbDrone to version {0}", _container.Resolve<EnvironmentProvider>().Version);
_kernel.Resolve<Program>().Start(args); _container.Resolve<Program>().Start(args);
} }
catch (Exception e) catch (Exception e)
{ {
@ -46,8 +48,8 @@ namespace NzbDrone.Update
{ {
try try
{ {
var environmentProvider = _kernel.Resolve<EnvironmentProvider>(); var environmentProvider = _container.Resolve<EnvironmentProvider>();
var diskProvider = _kernel.Resolve<DiskProvider>(); var diskProvider = _container.Resolve<DiskProvider>();
logger.Info("Copying log files to application directory."); logger.Info("Copying log files to application directory.");
diskProvider.CopyDirectory(environmentProvider.GetSandboxLogFolder(), environmentProvider.GetUpdateLogFolder()); diskProvider.CopyDirectory(environmentProvider.GetSandboxLogFolder(), environmentProvider.GetUpdateLogFolder());
} }
@ -59,7 +61,7 @@ namespace NzbDrone.Update
private static void InitLoggers() private static void InitLoggers()
{ {
ReportingService.RestProvider = _kernel.Resolve<RestProvider>(); ReportingService.RestProvider = _container.Resolve<RestProvider>();
ReportingService.SetupExceptronDriver(); ReportingService.SetupExceptronDriver();
LogConfiguration.RegisterRemote(); LogConfiguration.RegisterRemote();

Loading…
Cancel
Save