1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00

Move DB migration after application router

This commit is contained in:
Mark McDowall 2017-08-31 22:42:43 -07:00
parent 56825da6b6
commit bc32ad064e
No known key found for this signature in database
GPG Key ID: D4CEFA9A718052E0
2 changed files with 18 additions and 7 deletions

View File

@ -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<Router>().Route(applicationModes);
}

View File

@ -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: