adds better debug logging to scheduled publishing
This commit is contained in:
@@ -17,8 +17,15 @@ namespace Umbraco.Core.Publishing
|
||||
_contentService = contentService;
|
||||
}
|
||||
|
||||
public void CheckPendingAndProcess()
|
||||
/// <summary>
|
||||
/// Processes scheduled operations
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// Returns the number of items successfully completed
|
||||
/// </returns>
|
||||
public int CheckPendingAndProcess()
|
||||
{
|
||||
var counter = 0;
|
||||
foreach (var d in _contentService.GetContentForRelease())
|
||||
{
|
||||
try
|
||||
@@ -32,10 +39,14 @@ namespace Umbraco.Core.Publishing
|
||||
LogHelper.Error<ScheduledPublisher>("Could not published the document (" + d.Id + ") based on it's scheduled release, status result: " + result.Result.StatusType, result.Exception);
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
LogHelper.Warn<ScheduledPublisher>("Could not published the document (" + d.Id + ") based on it's scheduled release. Status result: " + result.Result.StatusType);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@@ -48,7 +59,11 @@ namespace Umbraco.Core.Publishing
|
||||
try
|
||||
{
|
||||
d.ExpireDate = null;
|
||||
_contentService.UnPublish(d, (int)d.GetWriterProfile().Id);
|
||||
var result = _contentService.UnPublish(d, (int)d.GetWriterProfile().Id);
|
||||
if (result)
|
||||
{
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@@ -56,6 +71,8 @@ namespace Umbraco.Core.Publishing
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
return counter;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,20 +49,32 @@ namespace Umbraco.Web.Scheduling
|
||||
return false; // do NOT repeat, going down
|
||||
}
|
||||
|
||||
using (DisposableTimer.DebugDuration<ScheduledPublishing>(() => "Scheduled publishing executing", () => "Scheduled publishing complete"))
|
||||
string umbracoAppUrl;
|
||||
try
|
||||
{
|
||||
string umbracoAppUrl = null;
|
||||
|
||||
try
|
||||
umbracoAppUrl = _appContext == null || _appContext.UmbracoApplicationUrl.IsNullOrWhiteSpace()
|
||||
? null
|
||||
: _appContext.UmbracoApplicationUrl;
|
||||
if (umbracoAppUrl.IsNullOrWhiteSpace())
|
||||
{
|
||||
umbracoAppUrl = _appContext.UmbracoApplicationUrl;
|
||||
if (umbracoAppUrl.IsNullOrWhiteSpace())
|
||||
{
|
||||
LogHelper.Warn<ScheduledPublishing>("No url for service (yet), skip.");
|
||||
return true; // repeat
|
||||
}
|
||||
LogHelper.Warn<ScheduledPublishing>("No url for service (yet), skip.");
|
||||
return true; // repeat
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogHelper.Error<ScheduledPublishing>("Could not acquire application url", e);
|
||||
return true; // repeat
|
||||
}
|
||||
|
||||
var url = umbracoAppUrl + "/RestServices/ScheduledPublish/Index";
|
||||
var url = umbracoAppUrl + "/RestServices/ScheduledPublish/Index";
|
||||
|
||||
using (DisposableTimer.DebugDuration<ScheduledPublishing>(
|
||||
() => string.Format("Scheduled publishing executing @ {0}", url),
|
||||
() => "Scheduled publishing complete"))
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var wc = new HttpClient())
|
||||
{
|
||||
var request = new HttpRequestMessage(HttpMethod.Post, url)
|
||||
|
||||
@@ -19,7 +19,11 @@ namespace Umbraco.Web.WebServices
|
||||
public JsonResult Index()
|
||||
{
|
||||
if (_isPublishingRunning)
|
||||
{
|
||||
Logger.Debug<ScheduledPublishController>(() => "Scheduled publishing is currently executing this request will exit");
|
||||
return null;
|
||||
}
|
||||
|
||||
_isPublishingRunning = true;
|
||||
|
||||
try
|
||||
@@ -28,7 +32,8 @@ namespace Umbraco.Web.WebServices
|
||||
if (content.Instance.isInitializing == false)
|
||||
{
|
||||
var publisher = new ScheduledPublisher(Services.ContentService);
|
||||
publisher.CheckPendingAndProcess();
|
||||
var count = publisher.CheckPendingAndProcess();
|
||||
Logger.Debug<ScheduledPublishController>(() => string.Format("The scheduler processed {0} items", count));
|
||||
}
|
||||
|
||||
return Json(new
|
||||
|
||||
Reference in New Issue
Block a user