From fc856b6abaa24d27cba5273147da11fc2446c1ba Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 6 Sep 2010 14:08:05 -0700 Subject: Add retry logic to the task framework. We retry 4 times with increasing backoff and if that fails, we put up a manual "retry" link. Fixes ticket #1270. --- .../gallery/views/admin_maintenance_task.html.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'modules/gallery/views') diff --git a/modules/gallery/views/admin_maintenance_task.html.php b/modules/gallery/views/admin_maintenance_task.html.php index 76756b66..013ac01f 100644 --- a/modules/gallery/views/admin_maintenance_task.html.php +++ b/modules/gallery/views/admin_maintenance_task.html.php @@ -3,6 +3,7 @@ var target_value; var animation = null; var delta = 1; + var consecutive_error_count = 0; animate_progress_bar = function() { var current_value = parseInt($(".g-progress-bar div").css("width").replace("%", "")); if (target_value > current_value) { @@ -26,12 +27,15 @@ $.fn.gallery_hover_init(); } + var FAILED_MSG = Retry or check the task log for details")->for_js() ?>; + var ERROR_MSG = for_js() ?>; update = function() { $.ajax({ url: id?csrf=$csrf")) ?>, dataType: "json", success: function(data) { target_value = data.task.percent_complete; + consecutive_error_count = 0; if (!animation) { animate_progress_bar(); } @@ -42,6 +46,22 @@ } else { setTimeout(update, 100); } + }, + error: function(req, textStatus, errorThrown) { + if (textStatus == "timeout" || textStatus == "parsererror") { + consecutive_error_count++; + if (consecutive_error_count == 5) { + $("#g-status").html(FAILED_MSG); + $("#g-pause-button").hide(); + $("#g-done-button").show(); + consecutive_error_count = 0; // in case of a manual retry + $("#g-status a").attr("href", "javascript:update()"); + } else { + $("#g-status").html(ERROR_MSG.replace("__COUNT__", consecutive_error_count)); + // Give a little time to back off before retrying + setTimeout(update, 1500 * consecutive_error_count); + } + } } }); } -- cgit v1.2.3 From cb22f23be64096234197cdb1c97d7a42ba504aa4 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 6 Sep 2010 14:16:26 -0700 Subject: Show the "view log" button for tasks that are running, in case they're paused/abandoned for some reason and we want to know more details. --- modules/gallery/views/admin_maintenance.html.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'modules/gallery/views') diff --git a/modules/gallery/views/admin_maintenance.html.php b/modules/gallery/views/admin_maintenance.html.php index 4bfc57f0..c28def1d 100644 --- a/modules/gallery/views/admin_maintenance.html.php +++ b/modules/gallery/views/admin_maintenance.html.php @@ -109,16 +109,21 @@ owner()->name) ?> - id?csrf=$csrf") ?>" - class="g-button g-right ui-icon-left ui-state-default ui-corner-all"> - - state == "stalled"): ?> id?csrf=$csrf") ?>"> + get_log()): ?> + id?csrf=$csrf") ?>" class="g-dialog-link g-button ui-state-default ui-corner-all"> + + + + id?csrf=$csrf") ?>" + class="g-button ui-icon-left ui-state-default ui-corner-all"> + + @@ -183,7 +188,7 @@ get_log()): ?> id?csrf=$csrf") ?>" class="g-dialog-link g-button ui-state-default ui-corner-all"> - + -- cgit v1.2.3