Move DB migration after application router

Mark McDowall 7 years ago
parent 56825da6b6
commit bc32ad064e
No known key found for this signature in database
GPG Key ID: D4CEFA9A718052E0

@ -1,4 +1,4 @@
using System;
using System;
using System.Reflection;
using System.Threading;
using NLog;
@ -9,7 +9,6 @@ using NzbDrone.Common.Instrumentation;
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 @@ namespace NzbDrone.Host
EnsureSingleInstance(applicationModes == ApplicationModes.Service, startupContext);
}
DbFactory.RegisterDatabase(_container);
_container.Resolve<Router>().Route(applicationModes);
}

@ -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 @@ namespace NzbDrone.Host
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 @@ namespace NzbDrone.Host
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:

Loading…
Cancel
Save