Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable HealthChecksUI if HealthChecks is not enabled #4780

Merged
merged 1 commit into from
Oct 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/Nethermind/Nethermind.HealthChecks/HealthChecksPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public class HealthChecksPlugin : INethermindPlugin, INethermindServicesPlugin

private ClHealthLogger _clHealthLogger;

private const int ClUnavailableReportMessageDelay = 5;
MarekM25 marked this conversation as resolved.
Show resolved Hide resolved

public async ValueTask DisposeAsync()
{
if (_clHealthLogger is not null)
Expand Down Expand Up @@ -74,6 +76,12 @@ public void AddServices(IServiceCollection service)
args: new object[] { _nodeHealthService, _api, _api.LogManager });
if (_healthChecksConfig.UIEnabled)
{
if (!_healthChecksConfig.Enabled)
{
if (_logger.IsWarn) _logger.Warn("To use HealthChecksUI please enable HealthChecks. (--HealthChecks.Enabled=true)");
return;
}

service.AddHealthChecksUI(setup =>
{
setup.AddHealthCheckEndpoint("health", BuildEndpointForUi());
Expand All @@ -89,8 +97,7 @@ public void AddServices(IServiceCollection service)
{
string description = report.Entries["node-health"].Description;

IMetricsConfig metricsConfig;
metricsConfig = _api.Config<IMetricsConfig>();
IMetricsConfig metricsConfig = _api.Config<IMetricsConfig>();

string hostname = Dns.GetHostName();

Expand Down Expand Up @@ -153,7 +160,7 @@ public ClHealthLogger(INodeHealthService nodeHealthService, ILogger logger)
public Task StartAsync(CancellationToken cancellationToken)
{
_timer = new Timer(ReportClStatus, null, TimeSpan.Zero,
TimeSpan.FromSeconds(5));
TimeSpan.FromSeconds(ClUnavailableReportMessageDelay));

return Task.CompletedTask;
}
Expand Down