From 0366fa73c33d12b3884b013ee3128bd29aec7572 Mon Sep 17 00:00:00 2001 From: AndyButland Date: Mon, 5 Jun 2017 10:14:17 +0200 Subject: [PATCH] Remove requirement for configuring start time for scheduled health checks; if not provided, start with short delay after application start --- .../HealthCheckNotificationSettingsElement.cs | 2 +- src/Umbraco.Web/Scheduling/Scheduler.cs | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Core/Configuration/HealthChecks/HealthCheckNotificationSettingsElement.cs b/src/Umbraco.Core/Configuration/HealthChecks/HealthCheckNotificationSettingsElement.cs index 8c533d9bac..0cb89be12f 100644 --- a/src/Umbraco.Core/Configuration/HealthChecks/HealthCheckNotificationSettingsElement.cs +++ b/src/Umbraco.Core/Configuration/HealthChecks/HealthCheckNotificationSettingsElement.cs @@ -24,7 +24,7 @@ namespace Umbraco.Core.Configuration.HealthChecks } } - [ConfigurationProperty(FIRST_RUN_TIME_KEY, IsRequired = true)] + [ConfigurationProperty(FIRST_RUN_TIME_KEY, IsRequired = false)] public string FirstRunTime { get diff --git a/src/Umbraco.Web/Scheduling/Scheduler.cs b/src/Umbraco.Web/Scheduling/Scheduler.cs index 85a5843486..6e470ad145 100644 --- a/src/Umbraco.Web/Scheduling/Scheduler.cs +++ b/src/Umbraco.Web/Scheduling/Scheduler.cs @@ -78,11 +78,21 @@ namespace Umbraco.Web.Scheduling if (healthCheckConfig.NotificationSettings.Enabled) { - var delayInMilliseconds = DateTime.Now.PeriodicMinutesFrom(healthCheckConfig.NotificationSettings.FirstRunTime) * 60 * 1000; - if (delayInMilliseconds < DelayMilliseconds) + // If first run time not set, start with just small delay after application start + int delayInMilliseconds; + if (string.IsNullOrEmpty(healthCheckConfig.NotificationSettings.FirstRunTime)) { delayInMilliseconds = DelayMilliseconds; } + else + { + // Otherwise start at scheduled time + delayInMilliseconds = DateTime.Now.PeriodicMinutesFrom(healthCheckConfig.NotificationSettings.FirstRunTime) * 60 * 1000; + if (delayInMilliseconds < DelayMilliseconds) + { + delayInMilliseconds = DelayMilliseconds; + } + } var periodInMilliseconds = healthCheckConfig.NotificationSettings.PeriodInHours * 60 * 60 * 1000; tasks.Add(new HealthCheckNotifier(_healthCheckRunner, delayInMilliseconds, periodInMilliseconds, e.UmbracoContext.Application));