Restart/shutdown messages

Restart/Shutodwn no longer use commands (should fix issues with restarts failing)
This commit is contained in:
Mark McDowall 2014-05-18 22:35:39 -07:00
parent d43e9785d5
commit 94f9db940b
4 changed files with 75 additions and 17 deletions

View file

@ -5,6 +5,8 @@ using NzbDrone.Api.Extensions;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Lifecycle;
using NzbDrone.Core.Lifecycle.Commands;
namespace NzbDrone.Api.System
{
@ -15,12 +17,14 @@ namespace NzbDrone.Api.System
private readonly IRouteCacheProvider _routeCacheProvider;
private readonly IConfigFileProvider _configFileProvider;
private readonly IDatabase _database;
private readonly ILifecycleService _lifecycleService;
public SystemModule(IAppFolderInfo appFolderInfo,
IRuntimeInfo runtimeInfo,
IRouteCacheProvider routeCacheProvider,
IConfigFileProvider configFileProvider,
IDatabase database)
IDatabase database,
ILifecycleService lifecycleService)
: base("system")
{
_appFolderInfo = appFolderInfo;
@ -28,8 +32,11 @@ namespace NzbDrone.Api.System
_routeCacheProvider = routeCacheProvider;
_configFileProvider = configFileProvider;
_database = database;
_lifecycleService = lifecycleService;
Get["/status"] = x => GetStatus();
Get["/routes"] = x => GetRoutes();
Post["/shutdown"] = x => Shutdown();
Post["/restart"] = x => Restart();
}
private Response GetStatus()
@ -62,5 +69,18 @@ namespace NzbDrone.Api.System
{
return _routeCacheProvider.GetCache().Values.AsResponse();
}
private Response Shutdown()
{
_lifecycleService.Shutdown();
return "".AsResponse();
}
private Response Restart()
{
_lifecycleService.Restart();
return "".AsResponse();
}
}
}