From 748eacfff22619055b2dd0578265b64a0fcd0525 Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Sun, 16 Aug 2026 19:13:31 +0200 Subject: [PATCH] Calibre-web reboot now waits for calibre-web to come back --- cps/static/js/main.js | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/cps/static/js/main.js b/cps/static/js/main.js index 7e4c02ca8..59345e44b 100644 --- a/cps/static/js/main.js +++ b/cps/static/js/main.js @@ -326,6 +326,20 @@ $(function() { $("#RestartDialog").modal("hide"); } + function waitForAdminAlive(onAvailable) { + var aliveInterval = setInterval(function () { + $.get({ + url: getPath() + "/admin/alive", + success: function (d, statusText, xhr) { + if (xhr.status < 400) { + clearInterval(aliveInterval); + onAvailable(); + } + }, + }); + }, 1000); + } + function cleanUp() { clearInterval(updateTimerID); $("#spinner2").hide(); @@ -456,7 +470,7 @@ $(function() { data: JSON.stringify({"parameter":0}), success: function success() { $("#spinner").show(); - setTimeout(restartTimer, 3000); + waitForAdminAlive(restartTimer); } }); }); @@ -781,26 +795,18 @@ $(function() { $("#flash_danger").remove(); $.post(getPath() + request_path, $(this).closest("form").serialize(), function(data) { $('#config_upload_formats').val(data.config_upload); - if(data.reboot) { + if (data.reboot) { $("#spinning_success").show(); - var rebootInterval = setInterval(function(){ - $.get({ - url:getPath() + "/admin/alive", - success: function (d, statusText, xhr) { - if (xhr.status < 400) { - $("#spinning_success").hide(); - clearInterval(rebootInterval); - if (data.result) { - handle_response(data.result); - data.result = ""; - } - } - }, - }); - }, 1000); + waitForAdminAlive(function () { + $("#spinning_success").hide(); + if (data.result) { + handle_response(data.result); + data.result = ""; + } + }); } else { handle_response(data.result); - } + } }); });