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.
47 lines
1.2 KiB
47 lines
1.2 KiB
6 years ago
|
using System.Diagnostics;
|
||
|
using NLog;
|
||
|
using NzbDrone.Common.EnvironmentInfo;
|
||
|
|
||
|
namespace NzbDrone.Core.HealthCheck.Checks
|
||
|
{
|
||
|
public class MonoDebugCheck : HealthCheckBase
|
||
|
{
|
||
|
private readonly Logger _logger;
|
||
|
private readonly StackFrameHelper _stackFrameHelper;
|
||
|
|
||
|
public override bool CheckOnSchedule => false;
|
||
|
|
||
|
public MonoDebugCheck(Logger logger, StackFrameHelper stackFrameHelper)
|
||
|
{
|
||
|
_logger = logger;
|
||
|
_stackFrameHelper = stackFrameHelper;
|
||
|
}
|
||
|
|
||
|
public class StackFrameHelper
|
||
|
{
|
||
|
public virtual bool HasStackFrameInfo()
|
||
|
{
|
||
|
var stackTrace = new StackTrace();
|
||
|
|
||
|
return stackTrace.FrameCount > 0 && stackTrace.GetFrame(0).GetFileColumnNumber() > 0;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public override HealthCheck Check()
|
||
|
{
|
||
|
if (!PlatformInfo.IsMono)
|
||
|
{
|
||
|
return new HealthCheck(GetType());
|
||
|
}
|
||
|
|
||
|
if (!_stackFrameHelper.HasStackFrameInfo())
|
||
|
{
|
||
|
_logger.Warn("Mono is not running with --debug switch");
|
||
|
return new HealthCheck(GetType());
|
||
|
}
|
||
|
|
||
|
return new HealthCheck(GetType());
|
||
|
}
|
||
|
}
|
||
|
}
|