You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
124 lines
4.8 KiB
124 lines
4.8 KiB
3 years ago
|
using System.IO;
|
||
7 years ago
|
using System.Threading.Tasks;
|
||
3 years ago
|
using Lidarr.Http;
|
||
|
using Lidarr.Http.Validation;
|
||
|
using Microsoft.AspNetCore.Mvc;
|
||
|
using Microsoft.AspNetCore.Routing;
|
||
|
using Microsoft.AspNetCore.Routing.Internal;
|
||
7 years ago
|
using NzbDrone.Common.EnvironmentInfo;
|
||
|
using NzbDrone.Common.Extensions;
|
||
|
using NzbDrone.Core.Configuration;
|
||
|
using NzbDrone.Core.Datastore;
|
||
|
using NzbDrone.Core.Lifecycle;
|
||
|
|
||
7 years ago
|
namespace Lidarr.Api.V1.System
|
||
7 years ago
|
{
|
||
3 years ago
|
[V1ApiController]
|
||
|
public class SystemController : Controller
|
||
7 years ago
|
{
|
||
|
private readonly IAppFolderInfo _appFolderInfo;
|
||
|
private readonly IRuntimeInfo _runtimeInfo;
|
||
|
private readonly IPlatformInfo _platformInfo;
|
||
|
private readonly IOsInfo _osInfo;
|
||
|
private readonly IConfigFileProvider _configFileProvider;
|
||
|
private readonly IMainDatabase _database;
|
||
|
private readonly ILifecycleService _lifecycleService;
|
||
5 years ago
|
private readonly IDeploymentInfoProvider _deploymentInfoProvider;
|
||
3 years ago
|
private readonly EndpointDataSource _endpointData;
|
||
|
private readonly DfaGraphWriter _graphWriter;
|
||
|
private readonly DuplicateEndpointDetector _detector;
|
||
7 years ago
|
|
||
3 years ago
|
public SystemController(IAppFolderInfo appFolderInfo,
|
||
|
IRuntimeInfo runtimeInfo,
|
||
|
IPlatformInfo platformInfo,
|
||
|
IOsInfo osInfo,
|
||
|
IConfigFileProvider configFileProvider,
|
||
|
IMainDatabase database,
|
||
|
ILifecycleService lifecycleService,
|
||
|
IDeploymentInfoProvider deploymentInfoProvider,
|
||
|
EndpointDataSource endpoints,
|
||
|
DfaGraphWriter graphWriter,
|
||
|
DuplicateEndpointDetector detector)
|
||
7 years ago
|
{
|
||
|
_appFolderInfo = appFolderInfo;
|
||
|
_runtimeInfo = runtimeInfo;
|
||
|
_platformInfo = platformInfo;
|
||
|
_osInfo = osInfo;
|
||
|
_configFileProvider = configFileProvider;
|
||
|
_database = database;
|
||
|
_lifecycleService = lifecycleService;
|
||
5 years ago
|
_deploymentInfoProvider = deploymentInfoProvider;
|
||
3 years ago
|
_endpointData = endpoints;
|
||
|
_graphWriter = graphWriter;
|
||
|
_detector = detector;
|
||
7 years ago
|
}
|
||
|
|
||
3 years ago
|
[HttpGet("status")]
|
||
|
public object GetStatus()
|
||
7 years ago
|
{
|
||
|
return new
|
||
6 years ago
|
{
|
||
7 years ago
|
Version = BuildInfo.Version.ToString(),
|
||
|
BuildTime = BuildInfo.BuildDateTime,
|
||
|
IsDebug = BuildInfo.IsDebug,
|
||
|
IsProduction = RuntimeInfo.IsProduction,
|
||
|
IsAdmin = _runtimeInfo.IsAdmin,
|
||
|
IsUserInteractive = RuntimeInfo.IsUserInteractive,
|
||
|
StartupPath = _appFolderInfo.StartUpFolder,
|
||
|
AppData = _appFolderInfo.GetAppDataPath(),
|
||
|
OsName = _osInfo.Name,
|
||
|
OsVersion = _osInfo.Version,
|
||
5 years ago
|
IsNetCore = PlatformInfo.IsNetCore,
|
||
7 years ago
|
IsLinux = OsInfo.IsLinux,
|
||
|
IsOsx = OsInfo.IsOsx,
|
||
|
IsWindows = OsInfo.IsWindows,
|
||
6 years ago
|
IsDocker = _osInfo.IsDocker,
|
||
7 years ago
|
Mode = _runtimeInfo.Mode,
|
||
|
Branch = _configFileProvider.Branch,
|
||
|
Authentication = _configFileProvider.AuthenticationMethod,
|
||
|
SqliteVersion = _database.Version,
|
||
7 years ago
|
MigrationVersion = _database.Migration,
|
||
7 years ago
|
UrlBase = _configFileProvider.UrlBase,
|
||
|
RuntimeVersion = _platformInfo.Version,
|
||
6 years ago
|
RuntimeName = PlatformInfo.Platform,
|
||
5 years ago
|
StartTime = _runtimeInfo.StartTime,
|
||
|
PackageVersion = _deploymentInfoProvider.PackageVersion,
|
||
|
PackageAuthor = _deploymentInfoProvider.PackageAuthor,
|
||
5 years ago
|
PackageUpdateMechanism = _deploymentInfoProvider.PackageUpdateMechanism,
|
||
|
PackageUpdateMechanismMessage = _deploymentInfoProvider.PackageUpdateMechanismMessage
|
||
5 years ago
|
};
|
||
7 years ago
|
}
|
||
|
|
||
3 years ago
|
[HttpGet("routes")]
|
||
|
public IActionResult GetRoutes()
|
||
7 years ago
|
{
|
||
3 years ago
|
using (var sw = new StringWriter())
|
||
|
{
|
||
|
_graphWriter.Write(_endpointData, sw);
|
||
|
var graph = sw.ToString();
|
||
|
return Content(graph, "text/plain");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
[HttpGet("routes/duplicate")]
|
||
|
public object DuplicateRoutes()
|
||
|
{
|
||
|
return _detector.GetDuplicateEndpoints(_endpointData);
|
||
7 years ago
|
}
|
||
|
|
||
3 years ago
|
[HttpPost("shutdown")]
|
||
|
public object Shutdown()
|
||
7 years ago
|
{
|
||
7 years ago
|
Task.Factory.StartNew(() => _lifecycleService.Shutdown());
|
||
5 years ago
|
return new { ShuttingDown = true };
|
||
7 years ago
|
}
|
||
|
|
||
3 years ago
|
[HttpPost("restart")]
|
||
|
public object Restart()
|
||
7 years ago
|
{
|
||
7 years ago
|
Task.Factory.StartNew(() => _lifecycleService.Restart());
|
||
5 years ago
|
return new { Restarting = true };
|
||
7 years ago
|
}
|
||
|
}
|
||
|
}
|