Autorefresh on healthchecks with config timeout
This commit is contained in:
parent
e42e00f19b
commit
5d098b1478
@ -50,7 +50,12 @@
|
|||||||
|
|
||||||
services.AddHealthChecks(checks =>
|
services.AddHealthChecks(checks =>
|
||||||
{
|
{
|
||||||
checks.AddSqlCheck("CatalogDb", Configuration["ConnectionString"]);
|
var minutes = 1;
|
||||||
|
if (int.TryParse(Configuration["HealthCheck:Timeout"], out var minutesParsed))
|
||||||
|
{
|
||||||
|
minutes = minutesParsed;
|
||||||
|
}
|
||||||
|
checks.AddSqlCheck("CatalogDb", Configuration["ConnectionString"], TimeSpan.FromMinutes(minutes));
|
||||||
});
|
});
|
||||||
|
|
||||||
services.AddMvc(options =>
|
services.AddMvc(options =>
|
||||||
|
@ -66,7 +66,12 @@ namespace eShopOnContainers.Identity
|
|||||||
|
|
||||||
services.AddHealthChecks(checks =>
|
services.AddHealthChecks(checks =>
|
||||||
{
|
{
|
||||||
checks.AddSqlCheck("Identity_Db", Configuration.GetConnectionString("DefaultConnection"));
|
var minutes = 1;
|
||||||
|
if (int.TryParse(Configuration["HealthCheck:Timeout"], out var minutesParsed))
|
||||||
|
{
|
||||||
|
minutes = minutesParsed;
|
||||||
|
}
|
||||||
|
checks.AddSqlCheck("Identity_Db", Configuration.GetConnectionString("DefaultConnection"), TimeSpan.FromMinutes(minutes));
|
||||||
});
|
});
|
||||||
|
|
||||||
services.AddTransient<IEmailSender, AuthMessageSender>();
|
services.AddTransient<IEmailSender, AuthMessageSender>();
|
||||||
|
@ -61,7 +61,12 @@
|
|||||||
|
|
||||||
services.AddHealthChecks(checks =>
|
services.AddHealthChecks(checks =>
|
||||||
{
|
{
|
||||||
checks.AddSqlCheck("OrderingDb", Configuration["ConnectionString"]);
|
var minutes = 1;
|
||||||
|
if (int.TryParse(Configuration["HealthCheck:Timeout"], out var minutesParsed))
|
||||||
|
{
|
||||||
|
minutes = minutesParsed;
|
||||||
|
}
|
||||||
|
checks.AddSqlCheck("OrderingDb", Configuration["ConnectionString"], TimeSpan.FromMinutes(minutes));
|
||||||
});
|
});
|
||||||
|
|
||||||
services.AddEntityFrameworkSqlServer()
|
services.AddEntityFrameworkSqlServer()
|
||||||
|
@ -54,10 +54,15 @@ namespace Microsoft.eShopOnContainers.WebMVC
|
|||||||
|
|
||||||
services.AddHealthChecks(checks =>
|
services.AddHealthChecks(checks =>
|
||||||
{
|
{
|
||||||
checks.AddUrlCheck(Configuration["CatalogUrl"]);
|
var minutes = 1;
|
||||||
checks.AddUrlCheck(Configuration["OrderingUrl"]);
|
if (int.TryParse(Configuration["HealthCheck:Timeout"], out var minutesParsed))
|
||||||
checks.AddUrlCheck(Configuration["BasketUrl"]);
|
{
|
||||||
checks.AddUrlCheck(Configuration["IdentityUrl"]);
|
minutes = minutesParsed;
|
||||||
|
}
|
||||||
|
checks.AddUrlCheck(Configuration["CatalogUrl"], TimeSpan.FromMinutes(minutes));
|
||||||
|
checks.AddUrlCheck(Configuration["OrderingUrl"], TimeSpan.FromMinutes(minutes));
|
||||||
|
checks.AddUrlCheck(Configuration["BasketUrl"], TimeSpan.FromMinutes(minutes));
|
||||||
|
checks.AddUrlCheck(Configuration["IdentityUrl"], TimeSpan.FromMinutes(minutes));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add application services.
|
// Add application services.
|
||||||
|
@ -45,10 +45,16 @@ namespace eShopConContainers.WebSPA
|
|||||||
{
|
{
|
||||||
services.AddHealthChecks(checks =>
|
services.AddHealthChecks(checks =>
|
||||||
{
|
{
|
||||||
checks.AddUrlCheck(Configuration["CatalogUrl"]);
|
var minutes = 1;
|
||||||
checks.AddUrlCheck(Configuration["OrderingUrl"]);
|
if (int.TryParse(Configuration["HealthCheck:Timeout"], out var minutesParsed))
|
||||||
checks.AddUrlCheck(Configuration["BasketUrl"]);
|
{
|
||||||
checks.AddUrlCheck(Configuration["IdentityUrl"]);
|
minutes = minutesParsed;
|
||||||
|
}
|
||||||
|
|
||||||
|
checks.AddUrlCheck(Configuration["CatalogUrl"], TimeSpan.FromMinutes(minutes));
|
||||||
|
checks.AddUrlCheck(Configuration["OrderingUrl"], TimeSpan.FromMinutes(minutes));
|
||||||
|
checks.AddUrlCheck(Configuration["BasketUrl"], TimeSpan.FromMinutes(minutes));
|
||||||
|
checks.AddUrlCheck(Configuration["IdentityUrl"], TimeSpan.FromMinutes(minutes));
|
||||||
});
|
});
|
||||||
|
|
||||||
services.Configure<AppSettings>(Configuration);
|
services.Configure<AppSettings>(Configuration);
|
||||||
|
@ -28,6 +28,7 @@ namespace WebStatus.Controllers
|
|||||||
data.AddResult(checkResult.Key, checkResult.Value);
|
data.AddResult(checkResult.Key, checkResult.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ViewBag.RefreshSeconds = 60;
|
||||||
return View(data);
|
return View(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,11 +8,11 @@ namespace WebStatus.Extensions
|
|||||||
{
|
{
|
||||||
public static class HealthCheckBuilderExtensions
|
public static class HealthCheckBuilderExtensions
|
||||||
{
|
{
|
||||||
public static HealthCheckBuilder AddUrlCheckIfNotNull(this HealthCheckBuilder builder, string url)
|
public static HealthCheckBuilder AddUrlCheckIfNotNull(this HealthCheckBuilder builder, string url, TimeSpan cacheDuration)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(url))
|
if (!string.IsNullOrEmpty(url))
|
||||||
{
|
{
|
||||||
builder.AddUrlCheck(url);
|
builder.AddUrlCheck(url, cacheDuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
return builder;
|
return builder;
|
||||||
|
@ -32,12 +32,18 @@ namespace WebStatus
|
|||||||
// Add framework services.
|
// Add framework services.
|
||||||
services.AddHealthChecks(checks =>
|
services.AddHealthChecks(checks =>
|
||||||
{
|
{
|
||||||
checks.AddUrlCheckIfNotNull(Configuration["OrderingUrl"]);
|
var minutes = 1;
|
||||||
checks.AddUrlCheckIfNotNull(Configuration["BasketUrl"]);
|
if (int.TryParse(Configuration["HealthCheck:Timeout"], out var minutesParsed))
|
||||||
checks.AddUrlCheckIfNotNull(Configuration["CatalogUrl"]);
|
{
|
||||||
checks.AddUrlCheckIfNotNull(Configuration["IdentityUrl"]);
|
minutes = minutesParsed;
|
||||||
checks.AddUrlCheckIfNotNull(Configuration["mvc"]);
|
}
|
||||||
checks.AddUrlCheckIfNotNull(Configuration["spa"]);
|
|
||||||
|
checks.AddUrlCheckIfNotNull(Configuration["OrderingUrl"], TimeSpan.FromMinutes(minutes));
|
||||||
|
checks.AddUrlCheckIfNotNull(Configuration["BasketUrl"], TimeSpan.FromMinutes(minutes));
|
||||||
|
checks.AddUrlCheckIfNotNull(Configuration["CatalogUrl"], TimeSpan.FromMinutes(minutes));
|
||||||
|
checks.AddUrlCheckIfNotNull(Configuration["IdentityUrl"], TimeSpan.FromMinutes(minutes));
|
||||||
|
checks.AddUrlCheckIfNotNull(Configuration["mvc"], TimeSpan.FromMinutes(minutes));
|
||||||
|
checks.AddUrlCheckIfNotNull(Configuration["spa"], TimeSpan.FromMinutes(minutes));
|
||||||
});
|
});
|
||||||
services.AddMvc();
|
services.AddMvc();
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,12 @@
|
|||||||
asp-fallback-test-class="sr-only" asp-fallback-test-property="position" asp-fallback-test-value="absolute" />
|
asp-fallback-test-class="sr-only" asp-fallback-test-property="position" asp-fallback-test-value="absolute" />
|
||||||
<link rel="stylesheet" href="~/css/site.min.css" asp-append-version="true" />
|
<link rel="stylesheet" href="~/css/site.min.css" asp-append-version="true" />
|
||||||
</environment>
|
</environment>
|
||||||
|
|
||||||
|
@if (ViewBag.RefreshSeconds != null && ViewBag.RefreshSeconds > 0)
|
||||||
|
{
|
||||||
|
<meta http-equiv="refresh" content="@ViewBag.RefreshSeconds">
|
||||||
|
}
|
||||||
|
|
||||||
@Html.Raw(JavaScriptSnippet.FullScript)
|
@Html.Raw(JavaScriptSnippet.FullScript)
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user