Improve manual update process with better user feedback (#7398)
This commit is contained in:
commit
5598a2ada4
2 changed files with 54 additions and 17 deletions
|
|
@ -8,8 +8,6 @@
|
||||||
|
|
||||||
class Upgrade extends Component
|
class Upgrade extends Component
|
||||||
{
|
{
|
||||||
public bool $showProgress = false;
|
|
||||||
|
|
||||||
public bool $updateInProgress = false;
|
public bool $updateInProgress = false;
|
||||||
|
|
||||||
public bool $isUpgradeAvailable = false;
|
public bool $isUpgradeAvailable = false;
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,10 @@ class="w-24 dark:bg-coolgray-200 dark:hover:bg-coolgray-300">Cancel
|
||||||
modalOpen: false,
|
modalOpen: false,
|
||||||
showProgress: false,
|
showProgress: false,
|
||||||
currentStatus: '',
|
currentStatus: '',
|
||||||
|
checkHealthInterval: null,
|
||||||
|
checkIfIamDeadInterval: null,
|
||||||
|
healthCheckAttempts: 0,
|
||||||
|
startTime: null,
|
||||||
confirmed() {
|
confirmed() {
|
||||||
this.showProgress = true;
|
this.showProgress = true;
|
||||||
this.$wire.$call('upgrade')
|
this.$wire.$call('upgrade')
|
||||||
|
|
@ -102,43 +106,78 @@ class="w-24 dark:bg-coolgray-200 dark:hover:bg-coolgray-300">Cancel
|
||||||
event.returnValue = '';
|
event.returnValue = '';
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
getReviveStatusMessage(elapsedMinutes, attempts) {
|
||||||
|
if (elapsedMinutes === 0) {
|
||||||
|
return `Waiting for Coolify to come back online... (attempt ${attempts})`;
|
||||||
|
} else if (elapsedMinutes < 2) {
|
||||||
|
return `Waiting for Coolify to come back online... (${elapsedMinutes} minute${elapsedMinutes !== 1 ? 's' : ''} elapsed)`;
|
||||||
|
} else if (elapsedMinutes < 5) {
|
||||||
|
return `Update in progress, this may take several minutes... (${elapsedMinutes} minutes elapsed)`;
|
||||||
|
} else if (elapsedMinutes < 10) {
|
||||||
|
return `Large updates can take 10+ minutes. Please be patient... (${elapsedMinutes} minutes elapsed)`;
|
||||||
|
} else {
|
||||||
|
return `Still updating. If this takes longer than 15 minutes, please check server logs... (${elapsedMinutes} minutes elapsed)`;
|
||||||
|
}
|
||||||
|
},
|
||||||
revive() {
|
revive() {
|
||||||
if (checkHealthInterval) return true;
|
if (this.checkHealthInterval) return true;
|
||||||
|
this.healthCheckAttempts = 0;
|
||||||
|
this.startTime = Date.now();
|
||||||
console.log('Checking server\'s health...')
|
console.log('Checking server\'s health...')
|
||||||
checkHealthInterval = setInterval(() => {
|
this.checkHealthInterval = setInterval(() => {
|
||||||
|
this.healthCheckAttempts++;
|
||||||
|
const elapsedMinutes = Math.floor((Date.now() - this.startTime) / 60000);
|
||||||
fetch('/api/health')
|
fetch('/api/health')
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
this.currentStatus =
|
this.currentStatus =
|
||||||
'Coolify is back online. Reloading this page (you can manually reload if its not done automatically)...';
|
'Coolify is back online. Reloading this page in 5 seconds...';
|
||||||
if (checkHealthInterval) clearInterval(
|
if (this.checkHealthInterval) {
|
||||||
checkHealthInterval);
|
clearInterval(this.checkHealthInterval);
|
||||||
|
this.checkHealthInterval = null;
|
||||||
|
}
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
}, 5000)
|
}, 5000)
|
||||||
} else {
|
} else {
|
||||||
this.currentStatus =
|
this.currentStatus = this.getReviveStatusMessage(elapsedMinutes, this
|
||||||
"Waiting for Coolify to come back from the dead..."
|
.healthCheckAttempts);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Health check failed:', error);
|
||||||
|
this.currentStatus = this.getReviveStatusMessage(elapsedMinutes, this
|
||||||
|
.healthCheckAttempts);
|
||||||
|
});
|
||||||
}, 2000);
|
}, 2000);
|
||||||
},
|
},
|
||||||
upgrade() {
|
upgrade() {
|
||||||
if (checkIfIamDeadInterval || this.$wire.showProgress) return true;
|
if (this.checkIfIamDeadInterval || this.showProgress) return true;
|
||||||
this.currentStatus = 'Pulling new images and updating Coolify.';
|
this.currentStatus = 'Update in progress. Pulling new images and preparing to restart Coolify...';
|
||||||
checkIfIamDeadInterval = setInterval(() => {
|
this.checkIfIamDeadInterval = setInterval(() => {
|
||||||
fetch('/api/health')
|
fetch('/api/health')
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
this.currentStatus = "Waiting for the update process..."
|
|
||||||
} else {
|
|
||||||
this.currentStatus =
|
this.currentStatus =
|
||||||
"Update done, restarting Coolify & waiting until it is revived!"
|
"Update in progress. Pulling new images and preparing to restart Coolify..."
|
||||||
if (checkIfIamDeadInterval) clearInterval(
|
} else {
|
||||||
checkIfIamDeadInterval);
|
this.currentStatus = "Coolify is restarting with the new version..."
|
||||||
|
if (this.checkIfIamDeadInterval) {
|
||||||
|
clearInterval(this.checkIfIamDeadInterval);
|
||||||
|
this.checkIfIamDeadInterval = null;
|
||||||
|
}
|
||||||
this.revive();
|
this.revive();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Health check failed:', error);
|
||||||
|
this.currentStatus = "Coolify is restarting with the new version..."
|
||||||
|
if (this.checkIfIamDeadInterval) {
|
||||||
|
clearInterval(this.checkIfIamDeadInterval);
|
||||||
|
this.checkIfIamDeadInterval = null;
|
||||||
|
}
|
||||||
|
this.revive();
|
||||||
|
});
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue