diff --git a/src/Umbraco.Web.UI/config/umbracoSettings.config b/src/Umbraco.Web.UI/config/umbracoSettings.config index 0a60537af5..840ac9cb66 100644 --- a/src/Umbraco.Web.UI/config/umbracoSettings.config +++ b/src/Umbraco.Web.UI/config/umbracoSettings.config @@ -224,7 +224,7 @@ - + 0 @@ -263,10 +263,7 @@ server1.mysite.com server1.mysite.com --> - - localhost - umb1.dev - umb2.dev + diff --git a/src/Umbraco.Web/Scheduling/KeepAlive.cs b/src/Umbraco.Web/Scheduling/KeepAlive.cs index 443c3727e1..e5092c2a7b 100644 --- a/src/Umbraco.Web/Scheduling/KeepAlive.cs +++ b/src/Umbraco.Web/Scheduling/KeepAlive.cs @@ -10,26 +10,30 @@ namespace Umbraco.Web.Scheduling { public static void Start(object sender) { - //NOTE: sender will be the umbraco ApplicationContext - - var appContext = sender as ApplicationContext; - if (appContext == null) return; - - var umbracoBaseUrl = ServerEnvironmentHelper.GetCurrentServerUmbracoBaseUrl(); - - var url = string.Format("{0}/ping.aspx", umbracoBaseUrl); - - try + using (DisposableTimer.DebugDuration(() => "Keep alive executing", () => "Keep alive complete")) { - using (var wc = new WebClient()) + //NOTE: sender will be the umbraco ApplicationContext + + var appContext = sender as ApplicationContext; + if (appContext == null) return; + + var umbracoBaseUrl = ServerEnvironmentHelper.GetCurrentServerUmbracoBaseUrl(); + + var url = string.Format("{0}/ping.aspx", umbracoBaseUrl); + + try { - wc.DownloadString(url); + using (var wc = new WebClient()) + { + wc.DownloadString(url); + } + } + catch (Exception ee) + { + LogHelper.Error("Error in ping", ee); } } - catch (Exception ee) - { - LogHelper.Error("Error in ping", ee); - } + } } } \ No newline at end of file diff --git a/src/Umbraco.Web/Scheduling/ScheduledPublishing.cs b/src/Umbraco.Web/Scheduling/ScheduledPublishing.cs index ef8d5ef65a..6bc5492973 100644 --- a/src/Umbraco.Web/Scheduling/ScheduledPublishing.cs +++ b/src/Umbraco.Web/Scheduling/ScheduledPublishing.cs @@ -16,35 +16,38 @@ namespace Umbraco.Web.Scheduling public void Start(object sender) { - //NOTE: sender will be the umbraco ApplicationContext + using (DisposableTimer.DebugDuration(() => "Scheduled publishing executing", () => "Scheduled publishing complete")) + { + //NOTE: sender will be the umbraco ApplicationContext - var appContext = sender as ApplicationContext; - if (appContext == null) return; + var appContext = sender as ApplicationContext; + if (appContext == null) return; - if (_isPublishingRunning) return; + if (_isPublishingRunning) return; - _isPublishingRunning = true; + _isPublishingRunning = true; - try - { - var umbracoBaseUrl = ServerEnvironmentHelper.GetCurrentServerUmbracoBaseUrl(); - var url = string.Format("{0}/RestServices/ScheduledPublish/", umbracoBaseUrl); - using (var wc = new WebClient()) + try { - //pass custom the authorization header - wc.Headers.Set("Authorization", AdminTokenAuthorizeAttribute.GetAuthHeaderTokenVal(appContext)); + var umbracoBaseUrl = ServerEnvironmentHelper.GetCurrentServerUmbracoBaseUrl(); + var url = string.Format("{0}/RestServices/ScheduledPublish/", umbracoBaseUrl); + using (var wc = new WebClient()) + { + //pass custom the authorization header + wc.Headers.Set("Authorization", AdminTokenAuthorizeAttribute.GetAuthHeaderTokenVal(appContext)); - var result = wc.UploadString(url, ""); + var result = wc.UploadString(url, ""); + } } - } - catch (Exception ee) - { - LogHelper.Error("An error occurred with the scheduled publishing", ee); - } - finally - { - _isPublishingRunning = false; - } + catch (Exception ee) + { + LogHelper.Error("An error occurred with the scheduled publishing", ee); + } + finally + { + _isPublishingRunning = false; + } + } } diff --git a/src/Umbraco.Web/Scheduling/ScheduledTasks.cs b/src/Umbraco.Web/Scheduling/ScheduledTasks.cs index 9abf7d9f69..526ebb0abb 100644 --- a/src/Umbraco.Web/Scheduling/ScheduledTasks.cs +++ b/src/Umbraco.Web/Scheduling/ScheduledTasks.cs @@ -6,6 +6,7 @@ using Umbraco.Core.Configuration; using Umbraco.Core.Logging; using Umbraco.Core.Publishing; using Umbraco.Core.Sync; +using Umbraco.Core; namespace Umbraco.Web.Scheduling { @@ -19,24 +20,28 @@ namespace Umbraco.Web.Scheduling public void Start(object sender) { - //NOTE: sender will be the umbraco ApplicationContext + using (DisposableTimer.DebugDuration(() => "Scheduled tasks executing", () => "Scheduled tasks complete")) + { + //NOTE: sender will be the umbraco ApplicationContext - if (_isPublishingRunning) return; + if (_isPublishingRunning) return; - _isPublishingRunning = true; + _isPublishingRunning = true; - try - { - ProcessTasks(); - } - catch (Exception ee) - { - LogHelper.Error("Error executing scheduled task", ee); - } - finally - { - _isPublishingRunning = false; + try + { + ProcessTasks(); + } + catch (Exception ee) + { + LogHelper.Error("Error executing scheduled task", ee); + } + finally + { + _isPublishingRunning = false; + } } + } private static void ProcessTasks() diff --git a/src/Umbraco.Web/Scheduling/Scheduler.cs b/src/Umbraco.Web/Scheduling/Scheduler.cs index 75930fed4c..db3ff1b5ed 100644 --- a/src/Umbraco.Web/Scheduling/Scheduler.cs +++ b/src/Umbraco.Web/Scheduling/Scheduler.cs @@ -1,5 +1,6 @@ using System.Threading; using Umbraco.Core; +using Umbraco.Core.Logging; using Umbraco.Core.Sync; namespace Umbraco.Web.Scheduling @@ -13,10 +14,10 @@ namespace Umbraco.Web.Scheduling /// in a web project nowadays. /// /// - internal sealed class Scheduler : ApplicationEventHandler - { - private Timer _pingTimer; - private Timer _schedulingTimer; + internal sealed class Scheduler : ApplicationEventHandler + { + private Timer _pingTimer; + private Timer _schedulingTimer; private LogScrubber _scrubber; protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) @@ -24,23 +25,23 @@ namespace Umbraco.Web.Scheduling if (umbracoApplication.Context == null) return; - // time to setup the tasks + // time to setup the tasks - // these are the legacy tasks - // just copied over here for backward compatibility - // of course we should have a proper scheduler, see #U4-809 + // these are the legacy tasks + // just copied over here for backward compatibility + // of course we should have a proper scheduler, see #U4-809 - // ping/keepalive + // ping/keepalive _pingTimer = new Timer(KeepAlive.Start, applicationContext, 60000, 300000); - // scheduled publishing/unpublishing - + // scheduled publishing/unpublishing + _schedulingTimer = new Timer(PerformScheduling, applicationContext, 30000, 60000); - + //log scrubbing _scrubber = new LogScrubber(); _scrubber.Start(); - } + } /// /// This performs all of the scheduling on the one timer @@ -51,32 +52,38 @@ namespace Umbraco.Web.Scheduling /// private static void PerformScheduling(object sender) { - - //get the current server status to see if this server should execute the scheduled publishing - var serverStatus = ServerEnvironmentHelper.GetStatus(); - - switch (serverStatus) + using (DisposableTimer.DebugDuration(() => "Scheduling interval executing", () => "Scheduling interval complete")) { - case CurrentServerEnvironmentStatus.Single: - case CurrentServerEnvironmentStatus.Master: - case CurrentServerEnvironmentStatus.Unknown: - //if it's a single server install, a master or it cannot be determined - // then we will process the scheduling + //get the current server status to see if this server should execute the scheduled publishing + var serverStatus = ServerEnvironmentHelper.GetStatus(); + + switch (serverStatus) + { + case CurrentServerEnvironmentStatus.Single: + case CurrentServerEnvironmentStatus.Master: + case CurrentServerEnvironmentStatus.Unknown: + //if it's a single server install, a master or it cannot be determined + // then we will process the scheduling - //do the scheduled publishing - var scheduledPublishing = new ScheduledPublishing(); - scheduledPublishing.Start(sender); + //do the scheduled publishing + var scheduledPublishing = new ScheduledPublishing(); + scheduledPublishing.Start(sender); - //do the scheduled tasks - var scheduledTasks = new ScheduledTasks(); - scheduledTasks.Start(sender); + //do the scheduled tasks + var scheduledTasks = new ScheduledTasks(); + scheduledTasks.Start(sender); - break; - case CurrentServerEnvironmentStatus.Slave: - //do not process - break; + break; + case CurrentServerEnvironmentStatus.Slave: + //do not process + + LogHelper.Debug( + () => string.Format("Current server ({0}) detected as a slave, no scheduled processes will execute on this server", NetworkHelper.MachineName)); + + break; + } } } - } + } }