update
This commit is contained in:
parent
4c999c3ff2
commit
7377f80bdd
@ -28,15 +28,17 @@
|
||||
@auth
|
||||
<script>
|
||||
function checkIfIamDead() {
|
||||
checkIfIamDeadInterval = setInterval(async () => {
|
||||
console.log('Checking server\'s pulse...')
|
||||
checkIfIamDeadInterval = setInterval(async () => {
|
||||
try {
|
||||
const res = await fetch('/api/health');
|
||||
if (!res.ok) {
|
||||
if (res.ok) {
|
||||
console.log('I\'m alive. Waiting for server to be dead...');
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('I\'m dead. Charging... Standby... Bzz... Bzz...')
|
||||
checkHealth();
|
||||
if (checkIfIamDeadInterval) clearInterval(checkIfIamDeadInterval);
|
||||
} else {
|
||||
console.log('I\'m alive. Waiting for server to be dead...');
|
||||
}
|
||||
|
||||
return;
|
||||
@ -44,16 +46,19 @@
|
||||
}
|
||||
|
||||
function checkHealth() {
|
||||
checkHealthInterval = setInterval(async () => {
|
||||
console.log('Checking server\'s health...')
|
||||
checkHealthInterval = setInterval(async () => {
|
||||
try {
|
||||
const res = await fetch('/api/health');
|
||||
if (res.ok) {
|
||||
console.log('Server is back online. Reloading...')
|
||||
if (checkHealthInterval) clearInterval(checkHealthInterval);
|
||||
window.location.reload();
|
||||
} else {
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('Waiting for server to come back from dead...');
|
||||
}
|
||||
|
||||
return;
|
||||
}, 2000);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user