From 9be2f99e7b7f7ecc9c643ef54fc5586cb77cc13c Mon Sep 17 00:00:00 2001 From: Stephan Date: Mon, 6 Jul 2015 17:47:21 +0200 Subject: [PATCH] Scheduler - does not run tasks if not MainDom --- src/Umbraco.Web/Scheduling/KeepAlive.cs | 23 ++++++++++++------- src/Umbraco.Web/Scheduling/LogScrubber.cs | 7 ++++++ .../Scheduling/ScheduledPublishing.cs | 7 ++++++ src/Umbraco.Web/Scheduling/ScheduledTasks.cs | 7 ++++++ 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/src/Umbraco.Web/Scheduling/KeepAlive.cs b/src/Umbraco.Web/Scheduling/KeepAlive.cs index d5ffbc811d..d11bf2af35 100644 --- a/src/Umbraco.Web/Scheduling/KeepAlive.cs +++ b/src/Umbraco.Web/Scheduling/KeepAlive.cs @@ -29,11 +29,18 @@ namespace Umbraco.Web.Scheduling { if (_appContext == null) return true; // repeat... - string umbracoAppUrl = null; - - try + // ensure we do not run if not main domain, but do NOT lock it + if (_appContext.MainDom.IsMainDom == false) { - using (DisposableTimer.DebugDuration(() => "Keep alive executing", () => "Keep alive complete")) + LogHelper.Debug("Does not run if not MainDom."); + return false; // do NOT repeat, going down + } + + using (DisposableTimer.DebugDuration(() => "Keep alive executing", () => "Keep alive complete")) + { + string umbracoAppUrl = null; + + try { umbracoAppUrl = _appContext.UmbracoApplicationUrl; if (umbracoAppUrl.IsNullOrWhiteSpace()) @@ -54,10 +61,10 @@ namespace Umbraco.Web.Scheduling var result = await wc.SendAsync(request, token); } } - } - catch (Exception e) - { - LogHelper.Error(string.Format("Failed (at \"{0}\").", umbracoAppUrl), e); + catch (Exception e) + { + LogHelper.Error(string.Format("Failed (at \"{0}\").", umbracoAppUrl), e); + } } return true; // repeat diff --git a/src/Umbraco.Web/Scheduling/LogScrubber.cs b/src/Umbraco.Web/Scheduling/LogScrubber.cs index 1083733003..14a7ea3211 100644 --- a/src/Umbraco.Web/Scheduling/LogScrubber.cs +++ b/src/Umbraco.Web/Scheduling/LogScrubber.cs @@ -65,6 +65,13 @@ namespace Umbraco.Web.Scheduling return false; // do NOT repeat, server status comes from config and will NOT change } + // ensure we do not run if not main domain, but do NOT lock it + if (_appContext.MainDom.IsMainDom == false) + { + LogHelper.Debug("Does not run if not MainDom."); + return false; // do NOT repeat, going down + } + using (DisposableTimer.DebugDuration("Log scrubbing executing", "Log scrubbing complete")) { Log.CleanLogs(GetLogScrubbingMaximumAge(_settings)); diff --git a/src/Umbraco.Web/Scheduling/ScheduledPublishing.cs b/src/Umbraco.Web/Scheduling/ScheduledPublishing.cs index 78a91f6341..11cffb3648 100644 --- a/src/Umbraco.Web/Scheduling/ScheduledPublishing.cs +++ b/src/Umbraco.Web/Scheduling/ScheduledPublishing.cs @@ -38,6 +38,13 @@ namespace Umbraco.Web.Scheduling return false; // do NOT repeat, server status comes from config and will NOT change } + // ensure we do not run if not main domain, but do NOT lock it + if (_appContext.MainDom.IsMainDom == false) + { + LogHelper.Debug("Does not run if not MainDom."); + return false; // do NOT repeat, going down + } + using (DisposableTimer.DebugDuration(() => "Scheduled publishing executing", () => "Scheduled publishing complete")) { string umbracoAppUrl = null; diff --git a/src/Umbraco.Web/Scheduling/ScheduledTasks.cs b/src/Umbraco.Web/Scheduling/ScheduledTasks.cs index 92214e5199..def7b606b5 100644 --- a/src/Umbraco.Web/Scheduling/ScheduledTasks.cs +++ b/src/Umbraco.Web/Scheduling/ScheduledTasks.cs @@ -101,6 +101,13 @@ namespace Umbraco.Web.Scheduling return false; // do NOT repeat, server status comes from config and will NOT change } + // ensure we do not run if not main domain, but do NOT lock it + if (_appContext.MainDom.IsMainDom == false) + { + LogHelper.Debug("Does not run if not MainDom."); + return false; // do NOT repeat, going down + } + using (DisposableTimer.DebugDuration(() => "Scheduled tasks executing", () => "Scheduled tasks complete")) { try