diff --git a/src/Umbraco.Infrastructure/HostedServices/HealthCheckNotifier.cs b/src/Umbraco.Infrastructure/HostedServices/HealthCheckNotifier.cs index 6a0828fad3..4b7656d20d 100644 --- a/src/Umbraco.Infrastructure/HostedServices/HealthCheckNotifier.cs +++ b/src/Umbraco.Infrastructure/HostedServices/HealthCheckNotifier.cs @@ -26,7 +26,7 @@ namespace Umbraco.Cms.Infrastructure.HostedServices /// public class HealthCheckNotifier : RecurringHostedServiceBase { - private readonly HealthChecksSettings _healthChecksSettings; + private HealthChecksSettings _healthChecksSettings; private readonly HealthCheckCollection _healthChecks; private readonly HealthCheckNotificationMethodCollection _notifications; private readonly IRuntimeState _runtimeState; @@ -50,7 +50,7 @@ namespace Umbraco.Cms.Infrastructure.HostedServices /// The profiling logger. /// Parser of crontab expressions. public HealthCheckNotifier( - IOptions healthChecksSettings, + IOptionsMonitor healthChecksSettings, HealthCheckCollection healthChecks, HealthCheckNotificationMethodCollection notifications, IRuntimeState runtimeState, @@ -61,10 +61,10 @@ namespace Umbraco.Cms.Infrastructure.HostedServices IProfilingLogger profilingLogger, ICronTabParser cronTabParser) : base( - healthChecksSettings.Value.Notification.Period, - healthChecksSettings.Value.GetNotificationDelay(cronTabParser, DateTime.Now, DefaultDelay)) + healthChecksSettings.CurrentValue.Notification.Period, + healthChecksSettings.CurrentValue.GetNotificationDelay(cronTabParser, DateTime.Now, DefaultDelay)) { - _healthChecksSettings = healthChecksSettings.Value; + _healthChecksSettings = healthChecksSettings.CurrentValue; _healthChecks = healthChecks; _notifications = notifications; _runtimeState = runtimeState; @@ -73,6 +73,12 @@ namespace Umbraco.Cms.Infrastructure.HostedServices _scopeProvider = scopeProvider; _logger = logger; _profilingLogger = profilingLogger; + + healthChecksSettings.OnChange(x => + { + _healthChecksSettings = x; + ChangePeriod(x.Notification.Period); + }); } public override async Task PerformExecuteAsync(object state)