diff --git a/src/NzbDrone.Host/Bootstrap.cs b/src/NzbDrone.Host/Bootstrap.cs index 39244c28a..b6aa700a6 100644 --- a/src/NzbDrone.Host/Bootstrap.cs +++ b/src/NzbDrone.Host/Bootstrap.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Reflection; using System.Threading; using NLog; @@ -9,7 +9,6 @@ using NzbDrone.Common.Processes; using NzbDrone.Common.Security; using NzbDrone.Core.Configuration; -using NzbDrone.Core.Datastore; using NzbDrone.Core.Instrumentation; namespace NzbDrone.Host @@ -76,7 +75,6 @@ private static void Start(ApplicationModes applicationModes, StartupContext star EnsureSingleInstance(applicationModes == ApplicationModes.Service, startupContext); } - DbFactory.RegisterDatabase(_container); _container.Resolve().Route(applicationModes); } diff --git a/src/NzbDrone.Host/Router.cs b/src/NzbDrone.Host/Router.cs index 72d1c8f67..efd9e4627 100644 --- a/src/NzbDrone.Host/Router.cs +++ b/src/NzbDrone.Host/Router.cs @@ -1,5 +1,7 @@ -using NLog; +using NLog; using NzbDrone.Common; +using NzbDrone.Common.Composition; +using NzbDrone.Core.Datastore; namespace NzbDrone.Host { @@ -8,14 +10,19 @@ public class Router private readonly INzbDroneServiceFactory _nzbDroneServiceFactory; private readonly IServiceProvider _serviceProvider; private readonly IConsoleService _consoleService; + private readonly IContainer _container; private readonly Logger _logger; - public Router(INzbDroneServiceFactory nzbDroneServiceFactory, IServiceProvider serviceProvider, - IConsoleService consoleService, Logger logger) + public Router(INzbDroneServiceFactory nzbDroneServiceFactory, + IServiceProvider serviceProvider, + IConsoleService consoleService, + IContainer container, + Logger logger) { _nzbDroneServiceFactory = nzbDroneServiceFactory; _serviceProvider = serviceProvider; _consoleService = consoleService; + _container = container; _logger = logger; } @@ -28,14 +35,20 @@ public void Route(ApplicationModes applicationModes) case ApplicationModes.Service: { _logger.Debug("Service selected"); + + DbFactory.RegisterDatabase(_container); _serviceProvider.Run(_nzbDroneServiceFactory.Build()); + break; } - + case ApplicationModes.Interactive: { _logger.Debug("Console selected"); + + DbFactory.RegisterDatabase(_container); _nzbDroneServiceFactory.Start(); + break; } case ApplicationModes.InstallService: