Add health check after deploy - confirms Arbiter restarted successfully

This commit is contained in:
Claude
2026-04-09 19:50:17 +00:00
parent 02bddc0baf
commit cbf5d219fc

View File

@@ -149,11 +149,47 @@
const data = await response.json();
if (data.success) {
icon.textContent = '✅';
text.textContent = 'Deployed!';
result.textContent = data.message;
// Deploy triggered, now wait for restart and check health
icon.textContent = '🔄';
text.textContent = 'Restarting...';
result.textContent = 'Waiting for Arbiter to come back online...';
result.classList.remove('hidden', 'text-red-500');
result.classList.add('text-green-500');
result.classList.add('text-yellow-500');
// Wait 4 seconds for restart, then check health
await new Promise(resolve => setTimeout(resolve, 4000));
// Poll for health (up to 3 attempts)
let healthy = false;
for (let i = 0; i < 3; i++) {
try {
const healthRes = await fetch('/admin/system/status', {
headers: { 'CSRF-Token': '<%= csrfToken %>' }
});
const healthData = await healthRes.json();
if (healthData.arbiter === 'running') {
healthy = true;
break;
}
} catch (e) {
// Server still restarting, wait and retry
await new Promise(resolve => setTimeout(resolve, 2000));
}
}
if (healthy) {
icon.textContent = '✅';
text.textContent = 'Deployed!';
result.textContent = 'Arbiter restarted successfully';
result.classList.remove('text-yellow-500', 'text-red-500');
result.classList.add('text-green-500');
} else {
icon.textContent = '⚠️';
text.textContent = 'Check Status';
result.textContent = 'Deploy triggered but could not confirm restart. Check logs.';
result.classList.remove('text-yellow-500', 'text-green-500');
result.classList.add('text-red-500');
}
} else {
icon.textContent = '❌';
text.textContent = 'Deploy Failed';