diff --git a/GWMS.UI/HealthChecks/Checks.cs b/GWMS.UI/Health/Checks.cs similarity index 89% rename from GWMS.UI/HealthChecks/Checks.cs rename to GWMS.UI/Health/Checks.cs index 57272b8..0fc5ed7 100644 --- a/GWMS.UI/HealthChecks/Checks.cs +++ b/GWMS.UI/Health/Checks.cs @@ -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); } } diff --git a/GWMS.UI/Startup.cs b/GWMS.UI/Startup.cs index fb317ae..0aba886 100644 --- a/GWMS.UI/Startup.cs +++ b/GWMS.UI/Startup.cs @@ -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(); diff --git a/GWMS.UI/appsettings.Development.json b/GWMS.UI/appsettings.Development.json index e3a86f7..b3efb2c 100644 --- a/GWMS.UI/appsettings.Development.json +++ b/GWMS.UI/appsettings.Development.json @@ -7,5 +7,5 @@ "Microsoft.Hosting.Lifetime": "Information" } }, - "ZCodeUrl": "http://IIS01/zcode/" + "ZCodeUrl": "http://10.74.82.218/zcode/" } \ No newline at end of file diff --git a/GWMS.UI/appsettings.Production.json b/GWMS.UI/appsettings.Production.json index 0074481..152c032 100644 --- a/GWMS.UI/appsettings.Production.json +++ b/GWMS.UI/appsettings.Production.json @@ -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/" } \ No newline at end of file