This commit is contained in:
@@ -63,19 +63,32 @@ namespace Sockeye.Biz
|
|||||||
{
|
{
|
||||||
//space things out a bit to not "Hammer" out calls
|
//space things out a bit to not "Hammer" out calls
|
||||||
await Task.Delay(1000);//1 second delay between calls
|
await Task.Delay(1000);//1 second delay between calls
|
||||||
//https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/health-checks?source=recommendations&view=aspnetcore-7.0
|
//https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/health-checks?source=recommendations&view=aspnetcore-7.0
|
||||||
//https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/health-checks?source=recommendations&view=aspnetcore-7.0#customize-the-http-status-code
|
//https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/health-checks?source=recommendations&view=aspnetcore-7.0#customize-the-http-status-code
|
||||||
//Basically it returns only plain text
|
//Basically it returns only plain text
|
||||||
//http status code = 200 for both Healthy and Degraded
|
//http status code = 200 for both Healthy and Degraded
|
||||||
//http status code = 503 for UnHealthy
|
//http status code = 503 for UnHealthy
|
||||||
//for our purposes anything other than 200 and "Healthy" is a problem
|
//for our purposes anything other than 200 and "Healthy" is a problem
|
||||||
|
|
||||||
var res = await client.GetAsync($"https://{srv.Name}/health");
|
HttpResponseMessage res = null;
|
||||||
var responseText = await res.Content.ReadAsStringAsync();
|
string responseText = string.Empty;
|
||||||
|
bool Failed = false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
res = await client.GetAsync($"https://{srv.Name}/health");
|
||||||
|
responseText = await res.Content.ReadAsStringAsync();
|
||||||
|
if (res.IsSuccessStatusCode && responseText == "Healthy")
|
||||||
|
Failed = false;
|
||||||
|
}
|
||||||
|
catch (System.Net.Http.HttpRequestException hex)
|
||||||
|
{
|
||||||
|
Failed = true;
|
||||||
|
responseText = $"Failure {hex.Message}";
|
||||||
|
}
|
||||||
srv.LastHealthCheck = DateTime.UtcNow;
|
srv.LastHealthCheck = DateTime.UtcNow;
|
||||||
srv.LastHealthStatus = responseText;
|
srv.LastHealthStatus = responseText;
|
||||||
log.LogDebug($"Health check server {srv.Name} response {responseText}");
|
log.LogDebug($"Health check server {srv.Name} response {responseText}");
|
||||||
if (res.IsSuccessStatusCode && responseText == "Healthy")
|
if (!Failed)
|
||||||
{
|
{
|
||||||
//a-ok
|
//a-ok
|
||||||
srv.ServerState = ServerState.ActiveHealthy;
|
srv.ServerState = ServerState.ActiveHealthy;
|
||||||
|
|||||||
Reference in New Issue
Block a user