fixing U4-11570 (#2860)
This commit is contained in:
committed by
Sebastiaan Janssen
parent
c4163e94c0
commit
f665f8af89
@@ -13,12 +13,15 @@ namespace Umbraco.Web.Scheduling
|
||||
internal class KeepAlive : RecurringTaskBase
|
||||
{
|
||||
private readonly ApplicationContext _appContext;
|
||||
private static HttpClient _httpClient;
|
||||
|
||||
public KeepAlive(IBackgroundTaskRunner<RecurringTaskBase> runner, int delayMilliseconds, int periodMilliseconds,
|
||||
public KeepAlive(IBackgroundTaskRunner<RecurringTaskBase> runner, int delayMilliseconds, int periodMilliseconds,
|
||||
ApplicationContext appContext)
|
||||
: base(runner, delayMilliseconds, periodMilliseconds)
|
||||
{
|
||||
_appContext = appContext;
|
||||
if (_httpClient == null)
|
||||
_httpClient = new HttpClient();
|
||||
}
|
||||
|
||||
private ILogger Logger { get { return _appContext.ProfilingLogger.Logger; } }
|
||||
@@ -26,7 +29,7 @@ namespace Umbraco.Web.Scheduling
|
||||
public override async Task<bool> PerformRunAsync(CancellationToken token)
|
||||
{
|
||||
if (_appContext == null) return true; // repeat...
|
||||
|
||||
|
||||
switch (_appContext.GetCurrentServerRole())
|
||||
{
|
||||
case ServerRole.Slave:
|
||||
@@ -58,11 +61,9 @@ namespace Umbraco.Web.Scheduling
|
||||
}
|
||||
|
||||
var url = umbracoAppUrl + "/ping.aspx";
|
||||
using (var wc = new HttpClient())
|
||||
{
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, url);
|
||||
var result = await wc.SendAsync(request, token);
|
||||
}
|
||||
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, url);
|
||||
var result = await _httpClient.SendAsync(request, token);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -78,4 +79,4 @@ namespace Umbraco.Web.Scheduling
|
||||
get { return true; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user