ASP.NET Core中的运行状况检查

时间:2020-09-27 20:10:11

标签: c# asp.net-core

我正在尝试进行“可选”健康检查;和可以在用户界面中用来确定某个功能是否可见的端点。

所以在ConfigureServices中,我是这样添加的:

.AddUrlGroup(new Uri(searchEngineConfig.Get<SearchEngineConfiguration>().Endpoint + SwaggerEndPoint), "Search API", failureStatus: HealthStatus.Degraded, tags: new string[] { "Optional", "Search" })

Configure中,我有这个

app.UseHealthChecks(HealthReadyEndPoint, new HealthCheckOptions()
    {
        Predicate = (check) => !check.Tags.Contains("Optional")
    });
app.UseHealthChecks(HealthLiveEndPoint, new HealthCheckOptions()
    {
        Predicate = (check) => false,
    });
app.UseHealthChecks(HealthSearchEndPoint, new HealthCheckOptions()
    {
        Predicate = (check) => check.Tags.Contains("Search")
    });

基本上,它很好用;只有当搜索引擎在启动时不可用时,ASP.NET Core应用程序似乎才根本无法启动,并不断抛出“拒绝连接”错误。

0 个答案:

没有答案