Auto-reconnect and reload after a successful restart (v0.16.24)

This commit is contained in:
marvin
2026-09-19 12:50:35 -04:00
parent 5ac088025a
commit 496716d4b2
5 changed files with 21 additions and 5 deletions
+15 -1
View File
@@ -607,7 +607,21 @@ function renderSystemPanel() {
const button = event.currentTarget;
if (!await themedConfirm("Restart Site Gateway?", "The application will stop and restart. This takes a few seconds and briefly interrupts hosted sites and the dashboard.", "Restart")) return;
button.disabled = true; button.textContent = "Restarting\u2026";
try { await api("/api/system/restart", { method: "POST" }); toast("Restarting \u2014 this dashboard will be unavailable briefly."); }
const restartStatus = document.querySelector("#system-restart-status");
try {
await api("/api/system/restart", { method: "POST" });
toast("Restarting \u2014 this dashboard will be unavailable briefly.");
button.textContent = "Waiting for Site Gateway\u2026";
if (restartStatus) restartStatus.textContent = "Reconnecting once Site Gateway comes back online\u2026";
for (let attempt = 0; attempt < 30; attempt++) {
await new Promise(resolve => setTimeout(resolve, 1000));
try {
const response = await fetch("/api/session", { cache: "no-store" });
if (response.ok) { location.reload(); return; }
} catch { /* Still restarting -- the dashboard is briefly unreachable while the container comes back up. */ }
}
location.reload();
}
catch (error) { toast(error.message, "error"); button.disabled = false; button.textContent = "Restart application"; }
});
}
+2 -2
View File
@@ -8,7 +8,7 @@
<title>Site Gateway</title>
<meta name="description" content="Host sites, proxy services, and manage HTTPS from one simple dashboard.">
<link rel="icon" type="image/png" href="/site-gateway-icon-approved.png">
<link rel="stylesheet" href="/styles.css?v=0.16.23">
<link rel="stylesheet" href="/styles.css?v=0.16.24">
</head>
<!-- ================================================================
@@ -434,6 +434,6 @@
<div id="toast" class="toast" role="status"></div>
<div id="update-banner" class="update-banner hidden" role="status"><span>A new version of Site Gateway is available.</span><div class="update-banner-actions"><button id="update-banner-refresh" class="button primary">Refresh</button><button id="update-banner-dismiss" class="text-button">Dismiss</button></div></div>
<!-- App scripts: core (app.js) then extended views/admin (features.js) -->
<script src="/app.js?v=0.16.23" defer></script><script src="/features.js?v=0.16.23" defer></script><script src="/select-enhance.js?v=0.16.23" defer></script>
<script src="/app.js?v=0.16.24" defer></script><script src="/features.js?v=0.16.24" defer></script><script src="/select-enhance.js?v=0.16.24" defer></script>
</body>
</html>