mirror of
https://github.com/Sonarr/Sonarr.git
synced 2025-03-05 15:15:59 +02:00
New: show mono version on System -> Info
This commit is contained in:
parent
e71de9cc29
commit
705d4a3d02
@ -21,7 +21,7 @@ namespace NzbDrone.Api.Frontend.Mappers
|
|||||||
_diskProvider = diskProvider;
|
_diskProvider = diskProvider;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
|
|
||||||
if (!RuntimeInfo.IsProduction)
|
if (!RuntimeInfoBase.IsProduction)
|
||||||
{
|
{
|
||||||
_caseSensitive = true;
|
_caseSensitive = true;
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ namespace NzbDrone.Api
|
|||||||
{
|
{
|
||||||
_logger.Info("Starting NzbDrone API");
|
_logger.Info("Starting NzbDrone API");
|
||||||
|
|
||||||
if (RuntimeInfo.IsProduction)
|
if (RuntimeInfoBase.IsProduction)
|
||||||
{
|
{
|
||||||
DiagnosticsHook.Disable(pipelines);
|
DiagnosticsHook.Disable(pipelines);
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ using Nancy.Routing;
|
|||||||
using NzbDrone.Common;
|
using NzbDrone.Common;
|
||||||
using NzbDrone.Api.Extensions;
|
using NzbDrone.Api.Extensions;
|
||||||
using NzbDrone.Common.EnvironmentInfo;
|
using NzbDrone.Common.EnvironmentInfo;
|
||||||
|
using NzbDrone.Common.Processes;
|
||||||
using NzbDrone.Core.Configuration;
|
using NzbDrone.Core.Configuration;
|
||||||
using NzbDrone.Core.Datastore;
|
using NzbDrone.Core.Datastore;
|
||||||
using NzbDrone.Core.Lifecycle;
|
using NzbDrone.Core.Lifecycle;
|
||||||
@ -46,9 +47,9 @@ namespace NzbDrone.Api.System
|
|||||||
Version = BuildInfo.Version.ToString(),
|
Version = BuildInfo.Version.ToString(),
|
||||||
BuildTime = BuildInfo.BuildDateTime,
|
BuildTime = BuildInfo.BuildDateTime,
|
||||||
IsDebug = BuildInfo.IsDebug,
|
IsDebug = BuildInfo.IsDebug,
|
||||||
IsProduction = RuntimeInfo.IsProduction,
|
IsProduction = RuntimeInfoBase.IsProduction,
|
||||||
IsAdmin = _runtimeInfo.IsAdmin,
|
IsAdmin = _runtimeInfo.IsAdmin,
|
||||||
IsUserInteractive = _runtimeInfo.IsUserInteractive,
|
IsUserInteractive = RuntimeInfoBase.IsUserInteractive,
|
||||||
StartupPath = _appFolderInfo.StartUpFolder,
|
StartupPath = _appFolderInfo.StartUpFolder,
|
||||||
AppData = _appFolderInfo.GetAppDataPath(),
|
AppData = _appFolderInfo.GetAppDataPath(),
|
||||||
OsVersion = OsInfo.Version.ToString(),
|
OsVersion = OsInfo.Version.ToString(),
|
||||||
@ -61,7 +62,8 @@ namespace NzbDrone.Api.System
|
|||||||
Authentication = _configFileProvider.AuthenticationEnabled,
|
Authentication = _configFileProvider.AuthenticationEnabled,
|
||||||
StartOfWeek = (int)OsInfo.FirstDayOfWeek,
|
StartOfWeek = (int)OsInfo.FirstDayOfWeek,
|
||||||
SqliteVersion = _database.Version,
|
SqliteVersion = _database.Version,
|
||||||
UrlBase = _configFileProvider.UrlBase
|
UrlBase = _configFileProvider.UrlBase,
|
||||||
|
RuntimeVersion = OsInfo.IsMono ? _runtimeInfo.RuntimeVersion : null
|
||||||
}.AsResponse();
|
}.AsResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ namespace NzbDrone.Common.Test
|
|||||||
[Test]
|
[Test]
|
||||||
public void IsProduction_should_return_false_when_run_within_nunit()
|
public void IsProduction_should_return_false_when_run_within_nunit()
|
||||||
{
|
{
|
||||||
RuntimeInfo.IsProduction.Should().BeFalse("Process name is " + Process.GetCurrentProcess().ProcessName + " Folder is " + Directory.GetCurrentDirectory());
|
RuntimeInfoBase.IsProduction.Should().BeFalse("Process name is " + Process.GetCurrentProcess().ProcessName + " Folder is " + Directory.GetCurrentDirectory());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
16
src/NzbDrone.Common/EnvironmentInfo/IRuntimeInfo.cs
Normal file
16
src/NzbDrone.Common/EnvironmentInfo/IRuntimeInfo.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace NzbDrone.Common.EnvironmentInfo
|
||||||
|
{
|
||||||
|
public interface IRuntimeInfo
|
||||||
|
{
|
||||||
|
Boolean IsUserInteractive { get; }
|
||||||
|
Boolean IsAdmin { get; }
|
||||||
|
Boolean IsWindowsService { get; }
|
||||||
|
Boolean IsConsole { get; }
|
||||||
|
Boolean IsRunning { get; set; }
|
||||||
|
Boolean RestartPending { get; set; }
|
||||||
|
String ExecutingApplication { get; }
|
||||||
|
String RuntimeVersion { get; }
|
||||||
|
}
|
||||||
|
}
|
@ -9,23 +9,12 @@ using NzbDrone.Common.Processes;
|
|||||||
|
|
||||||
namespace NzbDrone.Common.EnvironmentInfo
|
namespace NzbDrone.Common.EnvironmentInfo
|
||||||
{
|
{
|
||||||
public interface IRuntimeInfo
|
public abstract class RuntimeInfoBase : IRuntimeInfo
|
||||||
{
|
|
||||||
bool IsUserInteractive { get; }
|
|
||||||
bool IsAdmin { get; }
|
|
||||||
bool IsWindowsService { get; }
|
|
||||||
bool IsConsole { get; }
|
|
||||||
bool IsRunning { get; set; }
|
|
||||||
bool RestartPending { get; set; }
|
|
||||||
string ExecutingApplication { get; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class RuntimeInfo : IRuntimeInfo
|
|
||||||
{
|
{
|
||||||
private readonly Logger _logger;
|
private readonly Logger _logger;
|
||||||
private static readonly string ProcessName = Process.GetCurrentProcess().ProcessName.ToLower();
|
private static readonly string ProcessName = Process.GetCurrentProcess().ProcessName.ToLower();
|
||||||
|
|
||||||
public RuntimeInfo(Logger logger, IServiceProvider serviceProvider)
|
public RuntimeInfoBase(IServiceProvider serviceProvider, Logger logger)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
|
|
||||||
@ -43,16 +32,24 @@ namespace NzbDrone.Common.EnvironmentInfo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static RuntimeInfo()
|
static RuntimeInfoBase()
|
||||||
{
|
{
|
||||||
IsProduction = InternalIsProduction();
|
IsProduction = InternalIsProduction();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsUserInteractive
|
public static bool IsUserInteractive
|
||||||
{
|
{
|
||||||
get { return Environment.UserInteractive; }
|
get { return Environment.UserInteractive; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IRuntimeInfo.IsUserInteractive
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return IsUserInteractive;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public bool IsAdmin
|
public bool IsAdmin
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -79,7 +76,7 @@ namespace NzbDrone.Common.EnvironmentInfo
|
|||||||
return (OsInfo.IsWindows &&
|
return (OsInfo.IsWindows &&
|
||||||
IsUserInteractive &&
|
IsUserInteractive &&
|
||||||
ProcessName.Equals(ProcessProvider.NZB_DRONE_CONSOLE_PROCESS_NAME, StringComparison.InvariantCultureIgnoreCase)) ||
|
ProcessName.Equals(ProcessProvider.NZB_DRONE_CONSOLE_PROCESS_NAME, StringComparison.InvariantCultureIgnoreCase)) ||
|
||||||
OsInfo.IsMono;
|
OsInfo.IsMono;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,6 +84,8 @@ namespace NzbDrone.Common.EnvironmentInfo
|
|||||||
public bool RestartPending { get; set; }
|
public bool RestartPending { get; set; }
|
||||||
public string ExecutingApplication { get; private set; }
|
public string ExecutingApplication { get; private set; }
|
||||||
|
|
||||||
|
public abstract string RuntimeVersion { get; }
|
||||||
|
|
||||||
public static bool IsProduction { get; private set; }
|
public static bool IsProduction { get; private set; }
|
||||||
|
|
||||||
private static bool InternalIsProduction()
|
private static bool InternalIsProduction()
|
@ -30,7 +30,7 @@ namespace NzbDrone.Common.Instrumentation
|
|||||||
IncludeMachineName = true,
|
IncludeMachineName = true,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (RuntimeInfo.IsProduction)
|
if (RuntimeInfoBase.IsProduction)
|
||||||
{
|
{
|
||||||
config.ApiKey = "cc4728a35aa9414f9a0baa8eed56bc67";
|
config.ApiKey = "cc4728a35aa9414f9a0baa8eed56bc67";
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ namespace NzbDrone.Common.Instrumentation
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (inConsole && (OsInfo.IsMono || new RuntimeInfo(null, new ServiceProvider(new ProcessProvider())).IsUserInteractive))
|
if (inConsole && (OsInfo.IsMono || RuntimeInfoBase.IsUserInteractive))
|
||||||
{
|
{
|
||||||
RegisterConsole();
|
RegisterConsole();
|
||||||
}
|
}
|
||||||
@ -59,7 +59,7 @@ namespace NzbDrone.Common.Instrumentation
|
|||||||
{
|
{
|
||||||
var level = LogLevel.Trace;
|
var level = LogLevel.Trace;
|
||||||
|
|
||||||
if (RuntimeInfo.IsProduction)
|
if (RuntimeInfoBase.IsProduction)
|
||||||
{
|
{
|
||||||
level = LogLevel.Info;
|
level = LogLevel.Info;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ namespace NzbDrone.Common.Instrumentation
|
|||||||
{
|
{
|
||||||
string apiKey = string.Empty;
|
string apiKey = string.Empty;
|
||||||
|
|
||||||
if (RuntimeInfo.IsProduction)
|
if (RuntimeInfoBase.IsProduction)
|
||||||
{
|
{
|
||||||
apiKey = "4c4ecb69-d1b9-4e2a-b54b-b0c4cc143a95";
|
apiKey = "4c4ecb69-d1b9-4e2a-b54b-b0c4cc143a95";
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,8 @@
|
|||||||
<Compile Include="EnvironmentInfo\AppFolderInfo.cs" />
|
<Compile Include="EnvironmentInfo\AppFolderInfo.cs" />
|
||||||
<Compile Include="EnvironmentInfo\BuildInfo.cs" />
|
<Compile Include="EnvironmentInfo\BuildInfo.cs" />
|
||||||
<Compile Include="EnvironmentInfo\OsInfo.cs" />
|
<Compile Include="EnvironmentInfo\OsInfo.cs" />
|
||||||
<Compile Include="EnvironmentInfo\RuntimeInfo.cs" />
|
<Compile Include="EnvironmentInfo\IRuntimeInfo.cs" />
|
||||||
|
<Compile Include="EnvironmentInfo\RuntimeInfoBase.cs" />
|
||||||
<Compile Include="EnvironmentInfo\StartupContext.cs" />
|
<Compile Include="EnvironmentInfo\StartupContext.cs" />
|
||||||
<Compile Include="Exceptions\NotParentException.cs" />
|
<Compile Include="Exceptions\NotParentException.cs" />
|
||||||
<Compile Include="Exceptions\NzbDroneException.cs" />
|
<Compile Include="Exceptions\NzbDroneException.cs" />
|
||||||
@ -130,7 +131,6 @@
|
|||||||
<Compile Include="Model\ProcessInfo.cs" />
|
<Compile Include="Model\ProcessInfo.cs" />
|
||||||
<Compile Include="PathEqualityComparer.cs" />
|
<Compile Include="PathEqualityComparer.cs" />
|
||||||
<Compile Include="PathExtensions.cs" />
|
<Compile Include="PathExtensions.cs" />
|
||||||
<Compile Include="Processes\IRuntimeProvider.cs" />
|
|
||||||
<Compile Include="Processes\PidFileProvider.cs" />
|
<Compile Include="Processes\PidFileProvider.cs" />
|
||||||
<Compile Include="Processes\ProcessOutput.cs" />
|
<Compile Include="Processes\ProcessOutput.cs" />
|
||||||
<Compile Include="Processes\ProcessProvider.cs" />
|
<Compile Include="Processes\ProcessProvider.cs" />
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace NzbDrone.Common.Processes
|
|
||||||
{
|
|
||||||
public interface IRuntimeProvider
|
|
||||||
{
|
|
||||||
String GetVersion();
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,19 +2,18 @@
|
|||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Common.EnvironmentInfo;
|
using NzbDrone.Common.EnvironmentInfo;
|
||||||
using NzbDrone.Common.Processes;
|
|
||||||
|
|
||||||
namespace NzbDrone.Core.HealthCheck.Checks
|
namespace NzbDrone.Core.HealthCheck.Checks
|
||||||
{
|
{
|
||||||
public class MonoVersionCheck : HealthCheckBase
|
public class MonoVersionCheck : HealthCheckBase
|
||||||
{
|
{
|
||||||
private readonly IRuntimeProvider _runtimeProvider;
|
private readonly IRuntimeInfo _runtimeInfo;
|
||||||
private readonly Logger _logger;
|
private readonly Logger _logger;
|
||||||
private static readonly Regex VersionRegex = new Regex(@"(?<=\W|^)(?<version>\d+\.\d+\.\d+(\.\d+)?)(?=\W)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
private static readonly Regex VersionRegex = new Regex(@"(?<=\W|^)(?<version>\d+\.\d+\.\d+(\.\d+)?)(?=\W)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||||
|
|
||||||
public MonoVersionCheck(IRuntimeProvider runtimeProvider, Logger logger)
|
public MonoVersionCheck(IRuntimeInfo runtimeInfo, Logger logger)
|
||||||
{
|
{
|
||||||
_runtimeProvider = runtimeProvider;
|
_runtimeInfo = runtimeInfo;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,7 +24,7 @@ namespace NzbDrone.Core.HealthCheck.Checks
|
|||||||
return new HealthCheck(GetType());
|
return new HealthCheck(GetType());
|
||||||
}
|
}
|
||||||
|
|
||||||
var versionString = _runtimeProvider.GetVersion();
|
var versionString = _runtimeInfo.RuntimeVersion;
|
||||||
var versionMatch = VersionRegex.Match(versionString);
|
var versionMatch = VersionRegex.Match(versionString);
|
||||||
|
|
||||||
if (versionMatch.Success)
|
if (versionMatch.Success)
|
||||||
|
@ -39,7 +39,7 @@ namespace NzbDrone.Core.Housekeeping
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Only Vaccuum the DB in production
|
//Only Vaccuum the DB in production
|
||||||
if (RuntimeInfo.IsProduction)
|
if (RuntimeInfoBase.IsProduction)
|
||||||
{
|
{
|
||||||
// Vacuuming the log db isn't needed since that's done hourly at the TrimLogCommand.
|
// Vacuuming the log db isn't needed since that's done hourly at the TrimLogCommand.
|
||||||
_logger.Debug("Compressing main database after housekeeping");
|
_logger.Debug("Compressing main database after housekeeping");
|
||||||
|
@ -1,41 +1,45 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Common.Processes;
|
using NzbDrone.Common.EnvironmentInfo;
|
||||||
|
|
||||||
namespace NzbDrone.Mono
|
namespace NzbDrone.Mono
|
||||||
{
|
{
|
||||||
public class MonoRuntimeProvider : IRuntimeProvider
|
public class MonoRuntimeProvider : RuntimeInfoBase
|
||||||
{
|
{
|
||||||
private readonly Logger _logger;
|
private readonly Logger _logger;
|
||||||
|
|
||||||
public MonoRuntimeProvider(Logger logger)
|
public MonoRuntimeProvider(Common.IServiceProvider serviceProvider, Logger logger)
|
||||||
|
:base(serviceProvider, logger)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String GetVersion()
|
public override String RuntimeVersion
|
||||||
{
|
{
|
||||||
try
|
get
|
||||||
{
|
{
|
||||||
var type = Type.GetType("Mono.Runtime");
|
try
|
||||||
|
|
||||||
if (type != null)
|
|
||||||
{
|
{
|
||||||
var displayName = type.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static);
|
var type = Type.GetType("Mono.Runtime");
|
||||||
|
|
||||||
if (displayName != null)
|
if (type != null)
|
||||||
{
|
{
|
||||||
return displayName.Invoke(null, null).ToString();
|
var displayName = type.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static);
|
||||||
|
|
||||||
|
if (displayName != null)
|
||||||
|
{
|
||||||
|
return displayName.Invoke(null, null).ToString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
catch (Exception ex)
|
||||||
catch (Exception ex)
|
{
|
||||||
{
|
_logger.ErrorException("Unable to get mono version: " + ex.Message, ex);
|
||||||
_logger.ErrorException("Unable to get mono version: " + ex.Message, ex);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return String.Empty;
|
return String.Empty;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,22 @@
|
|||||||
using System;
|
using System;
|
||||||
using NzbDrone.Common.Processes;
|
using NLog;
|
||||||
|
using NzbDrone.Common.EnvironmentInfo;
|
||||||
|
|
||||||
namespace NzbDrone.Windows
|
namespace NzbDrone.Windows
|
||||||
{
|
{
|
||||||
public class DotNetRuntimeProvider : IRuntimeProvider
|
public class DotNetRuntimeProvider : RuntimeInfoBase
|
||||||
{
|
{
|
||||||
public String GetVersion()
|
public DotNetRuntimeProvider(Common.IServiceProvider serviceProvider, Logger logger)
|
||||||
|
: base(serviceProvider, logger)
|
||||||
{
|
{
|
||||||
return Environment.Version.ToString();
|
}
|
||||||
|
|
||||||
|
public override string RuntimeVersion
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Environment.Version.ToString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,15 @@
|
|||||||
<dl class="dl-horizontal">
|
<dl class="dl-horizontal">
|
||||||
<dt>Version</dt>
|
<dt>Version</dt>
|
||||||
<dd>{{version}}</dd>
|
<dd>{{version}}</dd>
|
||||||
|
|
||||||
|
{{#if isMono}}
|
||||||
|
<dt>Mono Version</dt>
|
||||||
|
<dd>{{runtimeVersion}}</dd>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
<dt>AppData directory</dt>
|
<dt>AppData directory</dt>
|
||||||
<dd>{{appData}}</dd>
|
<dd>{{appData}}</dd>
|
||||||
|
|
||||||
<dt>Startup directory</dt>
|
<dt>Startup directory</dt>
|
||||||
<dd>{{startupPath}}</dd>
|
<dd>{{startupPath}}</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user