Move DB migration to start

This commit is contained in:
Mark McDowall 2017-09-01 21:55:47 -07:00
parent ef8b882258
commit 6626397350
No known key found for this signature in database
GPG Key ID: D4CEFA9A718052E0
2 changed files with 8 additions and 9 deletions

View File

@ -1,8 +1,10 @@
using System;
using System;
using System.ServiceProcess;
using NLog;
using NzbDrone.Common.Composition;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Lifecycle;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Host.Owin;
@ -22,6 +24,7 @@ namespace NzbDrone.Host
private readonly IHostController _hostController;
private readonly IStartupContext _startupContext;
private readonly IBrowserService _browserService;
private readonly IContainer _container;
private readonly Logger _logger;
public NzbDroneServiceFactory(IConfigFileProvider configFileProvider,
@ -29,6 +32,7 @@ namespace NzbDrone.Host
IRuntimeInfo runtimeInfo,
IStartupContext startupContext,
IBrowserService browserService,
IContainer container,
Logger logger)
{
_configFileProvider = configFileProvider;
@ -36,6 +40,7 @@ namespace NzbDrone.Host
_runtimeInfo = runtimeInfo;
_startupContext = startupContext;
_browserService = browserService;
_container = container;
_logger = logger;
}
@ -52,6 +57,7 @@ namespace NzbDrone.Host
}
_runtimeInfo.IsExiting = false;
DbFactory.RegisterDatabase(_container);
_hostController.StartServer();
if (!_startupContext.Flags.Contains(StartupContext.NO_BROWSER)

View File

@ -1,8 +1,6 @@
using NLog;
using NzbDrone.Common;
using NzbDrone.Common.Composition;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Core.Datastore;
namespace NzbDrone.Host
{
@ -12,21 +10,18 @@ namespace NzbDrone.Host
private readonly IServiceProvider _serviceProvider;
private readonly IConsoleService _consoleService;
private readonly IRuntimeInfo _runtimeInfo;
private readonly IContainer _container;
private readonly Logger _logger;
public Router(INzbDroneServiceFactory nzbDroneServiceFactory,
IServiceProvider serviceProvider,
IConsoleService consoleService,
IRuntimeInfo runtimeInfo,
IContainer container,
Logger logger)
{
_nzbDroneServiceFactory = nzbDroneServiceFactory;
_serviceProvider = serviceProvider;
_consoleService = consoleService;
_runtimeInfo = runtimeInfo;
_container = container;
_logger = logger;
}
@ -40,7 +35,6 @@ namespace NzbDrone.Host
{
_logger.Debug("Service selected");
DbFactory.RegisterDatabase(_container);
_serviceProvider.Run(_nzbDroneServiceFactory.Build());
break;
@ -50,7 +44,6 @@ namespace NzbDrone.Host
{
_logger.Debug(_runtimeInfo.IsWindowsTray ? "Tray selected" : "Console selected");
DbFactory.RegisterDatabase(_container);
_nzbDroneServiceFactory.Start();
break;