Fix ping checks
This commit is contained in:
@@ -5,7 +5,7 @@ using System.Linq;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GWMS.UI.HealthChecks
|
||||
namespace GWMS.UI.Health
|
||||
{
|
||||
public class Checks
|
||||
{
|
||||
@@ -26,7 +26,7 @@ namespace GWMS.UI.HealthChecks
|
||||
return HealthCheckResult.Healthy(description, healthCheckData);
|
||||
}
|
||||
|
||||
return HealthCheckResult.Unhealthy(description, null, healthCheckData);
|
||||
return HealthCheckResult.Unhealthy(description + $" {hostName}", null, healthCheckData);
|
||||
}
|
||||
}
|
||||
|
||||
+10
-7
@@ -107,23 +107,23 @@ namespace GWMS.UI
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
// init DB
|
||||
string server = Configuration["DbConfig:Server"];
|
||||
string dbServerAddr = Configuration["DbConfig:Server"];
|
||||
string nKey = Configuration["DbConfig:nKey"];
|
||||
string sKey = Configuration["DbConfig:sKey"];
|
||||
|
||||
DbConfig.InitDb(server, nKey, sKey);
|
||||
DbConfig.InitDb(dbServerAddr, nKey, sKey);
|
||||
string connStringDB = DbConfig.CONNECTION_STRING;
|
||||
string connStringRedis = Configuration.GetConnectionString("Redis");
|
||||
string redisSrvAddr = connStringRedis.Substring(0, connStringRedis.IndexOf(":"));
|
||||
string qrCodeUri = Configuration["ZCodeUrl"];
|
||||
string qrCodeAddr = qrCodeUri.Replace("https://", "").Replace("http://", "").Substring(0, qrCodeUri.IndexOf("/"));
|
||||
var qrCodeUri = new Uri(Configuration["ZCodeUrl"]);
|
||||
string qrCodeAddr = qrCodeUri.Host;
|
||||
|
||||
// healthchecks
|
||||
services.AddHealthChecks()
|
||||
.AddMySql(connStringDB, "MySql instance")
|
||||
.AddAsyncCheck("DB PING", () => HealthChecks.Checks.PingCheck(server))
|
||||
.AddAsyncCheck("Redis PING", () => HealthChecks.Checks.PingCheck(redisSrvAddr))
|
||||
.AddAsyncCheck("QrCode PING", () => HealthChecks.Checks.PingCheck(qrCodeAddr))
|
||||
.AddAsyncCheck($"DB PING ({dbServerAddr})", () => Health.Checks.PingCheck(dbServerAddr))
|
||||
.AddAsyncCheck($"Redis PING ({redisSrvAddr})", () => Health.Checks.PingCheck(redisSrvAddr))
|
||||
.AddAsyncCheck($"QrCode PING ({qrCodeAddr})", () => Health.Checks.PingCheck(qrCodeAddr))
|
||||
.AddProcessAllocatedMemoryHealthCheck(512, "Max Process memory (<512MB)", failureStatus: HealthStatus.Degraded) // 512 MB max allocated memory
|
||||
.AddRedis(Configuration.GetConnectionString("Redis"), "Redis", failureStatus: HealthStatus.Degraded)
|
||||
.AddUrlGroup(new Uri(Configuration["ZCodeUrl"]), name: $"QrCode Gen ({Configuration["ZCodeUrl"]})", failureStatus: HealthStatus.Degraded);
|
||||
@@ -135,6 +135,9 @@ namespace GWMS.UI
|
||||
.AddHealthChecksUI(s =>
|
||||
{
|
||||
s.AddHealthCheckEndpoint("GWMS_Services", "health");
|
||||
s.SetEvaluationTimeInSeconds(5);
|
||||
s.SetApiMaxActiveRequests(5);
|
||||
s.SetHeaderText("GWMS Health Check Status");
|
||||
})
|
||||
.AddInMemoryStorage();
|
||||
|
||||
|
||||
@@ -7,5 +7,5 @@
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"ZCodeUrl": "http://IIS01/zcode/"
|
||||
"ZCodeUrl": "http://10.74.82.218/zcode/"
|
||||
}
|
||||
@@ -6,5 +6,17 @@
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"Redis": "localhost:6379",
|
||||
"AuthConnection": "Server=localhost;port=3306;database=GWMS;user=GWMS;pwd=GWMS_secret_pwd;sslmode=None;",
|
||||
"DefaultConnection": "Server=localhost;port=3306;database=GWMS;user=GWMS;pwd=GWMS_secret_pwd;sslmode=None;",
|
||||
"AdminConnection": "Server=localhost;port=3306;database=GWMS;user=root;pwd=Egalware_24068!;sslmode=None;",
|
||||
"GWMS.Data": "Server=localhost;port=3306;database=GWMS;user=GWMS;pwd=GWMS_secret_pwd;sslmode=None;"
|
||||
},
|
||||
"DbConfig": {
|
||||
"Server": "localhost",
|
||||
"nKey": "PZZFRR",
|
||||
"sKey": "M3T@n0"
|
||||
},
|
||||
"ZCodeUrl": "https://qrcode.steamware.net/"
|
||||
}
|
||||
Reference in New Issue
Block a user