fix 调试问题
This commit is contained in:
@@ -4,7 +4,7 @@ namespace Dlhis.Middle.Services.Implements;
|
||||
|
||||
public class HealthCheckService : IHealthCheckService
|
||||
{
|
||||
private bool _isOffline = true;
|
||||
private bool _isOffline = false;
|
||||
private readonly string _hostName;
|
||||
private readonly ILogger<HealthCheckService> _logger;
|
||||
private int _successRetry;
|
||||
@@ -26,14 +26,14 @@ public class HealthCheckService : IHealthCheckService
|
||||
var tcpClient = new TcpClient();
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("tcp connecting {host} {port}", _hostName, 443);
|
||||
_logger.LogDebug("tcp connecting {host} {port}", _hostName, 443);
|
||||
await tcpClient.ConnectAsync(_hostName, 443);
|
||||
_retry++;
|
||||
_logger.LogInformation("retry {retry}", _retry);
|
||||
_logger.LogDebug("retry {retry}", _retry);
|
||||
if (tcpClient.Connected)
|
||||
{
|
||||
_successRetry++;
|
||||
_logger.LogInformation("success connected {count}", _successRetry);
|
||||
_logger.LogDebug("success connected {count}", _successRetry);
|
||||
if (_successRetry == 4)
|
||||
{
|
||||
_isOffline = false;
|
||||
@@ -43,7 +43,7 @@ public class HealthCheckService : IHealthCheckService
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogInformation("wait next check in {waitTime}", _successRetry * 1000);
|
||||
_logger.LogDebug("wait next check in {waitTime}", _successRetry * 1000);
|
||||
await Task.Delay(_successRetry * 1000);
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@ public class HealthCheckService : IHealthCheckService
|
||||
{
|
||||
_successRetry = 0;
|
||||
_isOffline = true;
|
||||
_logger.LogInformation("current is {status}", "unavailable");
|
||||
_logger.LogDebug("current is {status}", "unavailable");
|
||||
await Task.Delay(2000);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user