U4-5728 - Do not run KeepAlive, ScheduledPublishing, without an url

Updates the scheduler and the scheduled tasks to use a background task runner (ported from new courier codebase with tests) so that they are web aware and wind down properly.
This commit is contained in:
Shannon
2014-11-12 16:00:17 +11:00
parent b8ea50d644
commit b1d4a99510
12 changed files with 922 additions and 142 deletions

View File

@@ -1,6 +1,8 @@
using System;
using System.Net;
using Umbraco.Core;
using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.Logging;
using Umbraco.Core.Sync;
@@ -8,24 +10,33 @@ namespace Umbraco.Web.Scheduling
{
internal class KeepAlive
{
public static void Start(object sender)
public static void Start(ApplicationContext appContext, IUmbracoSettingsSection settings)
{
using (DisposableTimer.DebugDuration<KeepAlive>(() => "Keep alive executing", () => "Keep alive complete"))
{
var umbracoBaseUrl = ServerEnvironmentHelper.GetCurrentServerUmbracoBaseUrl();
var umbracoBaseUrl = ServerEnvironmentHelper.GetCurrentServerUmbracoBaseUrl(
appContext,
settings);
var url = string.Format("{0}/ping.aspx", umbracoBaseUrl);
try
if (string.IsNullOrWhiteSpace(umbracoBaseUrl))
{
using (var wc = new WebClient())
{
wc.DownloadString(url);
}
LogHelper.Warn<KeepAlive>("No url for service (yet), skip.");
}
catch (Exception ee)
else
{
LogHelper.Error<KeepAlive>("Error in ping", ee);
var url = string.Format("{0}/ping.aspx", umbracoBaseUrl);
try
{
using (var wc = new WebClient())
{
wc.DownloadString(url);
}
}
catch (Exception ee)
{
LogHelper.Error<KeepAlive>("Error in ping", ee);
}
}
}