mirror of
https://github.com/Sonarr/Sonarr.git
synced 2025-01-10 23:29:53 +02:00
Fixed: Prevent lack of internet from stopping all health checks from running
This commit is contained in:
parent
b51a490979
commit
dba3a82439
@ -23,19 +23,26 @@ public SystemTimeCheck(IHttpClient client, ISonarrCloudRequestBuilder cloudReque
|
|||||||
|
|
||||||
public override HealthCheck Check()
|
public override HealthCheck Check()
|
||||||
{
|
{
|
||||||
var request = _cloudRequestBuilder.Create()
|
try
|
||||||
.Resource("/time")
|
|
||||||
.Build();
|
|
||||||
|
|
||||||
var response = _client.Execute(request);
|
|
||||||
var result = Json.Deserialize<ServiceTimeResponse>(response.Content);
|
|
||||||
var systemTime = DateTime.UtcNow;
|
|
||||||
|
|
||||||
// +/- more than 1 day
|
|
||||||
if (Math.Abs(result.DateTimeUtc.Subtract(systemTime).TotalDays) >= 1)
|
|
||||||
{
|
{
|
||||||
_logger.Error("System time mismatch. SystemTime: {0} Expected Time: {1}. Update system time", systemTime, result.DateTimeUtc);
|
var request = _cloudRequestBuilder.Create()
|
||||||
return new HealthCheck(GetType(), HealthCheckResult.Error, _localizationService.GetLocalizedString("SystemTimeHealthCheckMessage"), "#system-time-off");
|
.Resource("/time")
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var response = _client.Execute(request);
|
||||||
|
var result = Json.Deserialize<ServiceTimeResponse>(response.Content);
|
||||||
|
var systemTime = DateTime.UtcNow;
|
||||||
|
|
||||||
|
// +/- more than 1 day
|
||||||
|
if (Math.Abs(result.DateTimeUtc.Subtract(systemTime).TotalDays) >= 1)
|
||||||
|
{
|
||||||
|
_logger.Error("System time mismatch. SystemTime: {0} Expected Time: {1}. Update system time", systemTime, result.DateTimeUtc);
|
||||||
|
return new HealthCheck(GetType(), HealthCheckResult.Error, _localizationService.GetLocalizedString("SystemTimeHealthCheckMessage"), "#system-time-off");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
_logger.Warn(e, "Unable to verify system time");
|
||||||
}
|
}
|
||||||
|
|
||||||
return new HealthCheck(GetType());
|
return new HealthCheck(GetType());
|
||||||
|
Loading…
Reference in New Issue
Block a user