Updates health check config to work the Umbraco/Testable way

This commit is contained in:
Shannon
2017-08-02 22:32:28 +10:00
parent 6aeb1a8845
commit df287f291e
22 changed files with 281 additions and 92 deletions

View File

@@ -3,6 +3,7 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Umbraco.Core;
using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.HealthChecks;
using Umbraco.Core.Logging;
using Umbraco.Core.Sync;
@@ -44,9 +45,9 @@ namespace Umbraco.Web.Scheduling
return false; // do NOT repeat, going down
}
using (DisposableTimer.DebugDuration<KeepAlive>(() => "Health checks executing", () => "Health checks complete"))
using (_appContext.ProfilingLogger.DebugDuration<KeepAlive>("Health checks executing", "Health checks complete"))
{
var healthCheckConfig = (HealthChecksSection)ConfigurationManager.GetSection("umbracoConfiguration/HealthChecks");
var healthCheckConfig = UmbracoConfig.For.HealthCheck();
// Don't notify for any checks that are disabled, nor for any disabled
// just for notifications

View File

@@ -6,6 +6,7 @@ using Umbraco.Core;
using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.HealthChecks;
using Umbraco.Core.Logging;
using Umbraco.Web.HealthCheck;
using Umbraco.Web.Routing;
namespace Umbraco.Web.Scheduling
@@ -65,15 +66,15 @@ namespace Umbraco.Web.Scheduling
LogHelper.Debug<Scheduler>(() => "Initializing the scheduler");
var settings = UmbracoConfig.For.UmbracoSettings();
var healthCheckConfig = (HealthChecksSection)ConfigurationManager.GetSection("umbracoConfiguration/HealthChecks");
var healthCheckConfig = UmbracoConfig.For.HealthCheck();
const int DelayMilliseconds = 60000;
const int delayMilliseconds = 60000;
var tasks = new List<IBackgroundTask>
{
new KeepAlive(_keepAliveRunner, DelayMilliseconds, 300000, e.UmbracoContext.Application),
new ScheduledPublishing(_publishingRunner, DelayMilliseconds, 60000, e.UmbracoContext.Application, settings),
new ScheduledTasks(_tasksRunner, DelayMilliseconds, 60000, e.UmbracoContext.Application, settings),
new LogScrubber(_scrubberRunner, DelayMilliseconds, LogScrubber.GetLogScrubbingInterval(settings), e.UmbracoContext.Application, settings),
new KeepAlive(_keepAliveRunner, delayMilliseconds, 300000, e.UmbracoContext.Application),
new ScheduledPublishing(_publishingRunner, delayMilliseconds, 60000, e.UmbracoContext.Application, settings),
new ScheduledTasks(_tasksRunner, delayMilliseconds, 60000, e.UmbracoContext.Application, settings),
new LogScrubber(_scrubberRunner, delayMilliseconds, LogScrubber.GetLogScrubbingInterval(settings), e.UmbracoContext.Application, settings),
};
if (healthCheckConfig.NotificationSettings.Enabled)
@@ -82,15 +83,15 @@ namespace Umbraco.Web.Scheduling
int delayInMilliseconds;
if (string.IsNullOrEmpty(healthCheckConfig.NotificationSettings.FirstRunTime))
{
delayInMilliseconds = DelayMilliseconds;
delayInMilliseconds = delayMilliseconds;
}
else
{
// Otherwise start at scheduled time
delayInMilliseconds = DateTime.Now.PeriodicMinutesFrom(healthCheckConfig.NotificationSettings.FirstRunTime) * 60 * 1000;
if (delayInMilliseconds < DelayMilliseconds)
if (delayInMilliseconds < delayMilliseconds)
{
delayInMilliseconds = DelayMilliseconds;
delayInMilliseconds = delayMilliseconds;
}
}