U4-10538 Disable Ping on front-end nodes when load balancing

This commit is contained in:
Shannon
2017-10-16 16:22:10 +11:00
parent a2e6da2491
commit fd8daa398f
2 changed files with 16 additions and 3 deletions

View File

@@ -6,6 +6,7 @@ using System.Threading.Tasks;
using Umbraco.Core;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.Logging;
using Umbraco.Core.Sync;
namespace Umbraco.Web.Scheduling
{
@@ -20,9 +21,21 @@ namespace Umbraco.Web.Scheduling
_appContext = appContext;
}
private ILogger Logger { get { return _appContext.ProfilingLogger.Logger; } }
public override async Task<bool> PerformRunAsync(CancellationToken token)
{
if (_appContext == null) return true; // repeat...
switch (_appContext.GetCurrentServerRole())
{
case ServerRole.Slave:
Logger.Debug<ScheduledPublishing>("Does not run on slave servers.");
return true; // DO repeat, server role can change
case ServerRole.Unknown:
Logger.Debug<ScheduledPublishing>("Does not run on servers with unknown role.");
return true; // DO repeat, server role can change
}
// ensure we do not run if not main domain, but do NOT lock it
if (_appContext.MainDom.IsMainDom == false)
@@ -31,7 +44,7 @@ namespace Umbraco.Web.Scheduling
return false; // do NOT repeat, going down
}
using (DisposableTimer.DebugDuration<KeepAlive>(() => "Keep alive executing", () => "Keep alive complete"))
using (_appContext.ProfilingLogger.DebugDuration<KeepAlive>("Keep alive executing", "Keep alive complete"))
{
string umbracoAppUrl = null;

View File

@@ -31,7 +31,7 @@ namespace Umbraco.Web.Scheduling
private ILogger Logger { get { return _appContext.ProfilingLogger.Logger; } }
public override async Task<bool> PerformRunAsync(CancellationToken token)
public override bool PerformRun()
{
if (_appContext == null) return true; // repeat...
@@ -94,7 +94,7 @@ namespace Umbraco.Web.Scheduling
public override bool IsAsync
{
get { return true; }
get { return false; }
}
}
}