This commit is contained in:
Andras Bacsai 2023-06-15 11:55:17 +02:00
parent 8dcb790d12
commit 890f0819ad
3 changed files with 43 additions and 45 deletions

View File

@ -25,7 +25,7 @@ class Upgrade extends Component
try { try {
$this->showProgress = true; $this->showProgress = true;
resolve(UpdateCoolify::class)(true); resolve(UpdateCoolify::class)(true);
Toaster::success('Update started.'); Toaster::success('Upgrading Coolify to latest version...');
} catch (\Exception $e) { } catch (\Exception $e) {
return general_error_handler(err: $e, that: $this); return general_error_handler(err: $e, that: $this);
} }

View File

@ -39,6 +39,46 @@
<x-version class="fixed left-2 bottom-1" /> <x-version class="fixed left-2 bottom-1" />
@auth @auth
<script> <script>
let checkHealthInterval = null;
let checkIfIamDeadInterval = null;
function revive() {
console.log('Checking server\'s health...')
checkHealthInterval = setInterval(() => {
fetch('/api/health')
.then(response => {
if (response.ok) {
Toaster.success('Coolify is back online. Reloading...')
if (checkHealthInterval) clearInterval(checkHealthInterval);
setTimeout(() => {
window.location.reload();
}, 5000)
} else {
console.log('Waiting for server to come back from dead...');
}
})
return;
}, 2000);
}
function upgrade() {
console.log('Update initiated.')
checkIfIamDeadInterval = setInterval(() => {
fetch('/api/health')
.then(response => {
if (response.ok) {
console.log('It\'s alive. Waiting for server to be dead...');
} else {
Toaster.success('Update done, restarting Coolify!')
console.log('It\'s dead. Reviving... Standby... Bzz... Bzz...')
if (checkIfIamDeadInterval) clearInterval(checkIfIamDeadInterval);
revive();
}
})
return;
}, 2000);
}
function changePasswordFieldType(id) { function changePasswordFieldType(id) {
const input = document.getElementById(id); const input = document.getElementById(id);
if (input.type === 'password') { if (input.type === 'password') {

View File

@ -1,6 +1,6 @@
<li title="New version available" x-init="$wire.checkUpdate"> <li title="New version available" x-init="$wire.checkUpdate" x-data>
@if ($isUpgradeAvailable) @if ($isUpgradeAvailable)
<div x-data wire:click='upgrade' class=" hover:bg-transparent focus:bg-transparent" x-on:click="upgrade" <button> <div wire:click='upgrade' class="hover:bg-transparent focus:bg-transparent" x-on:click="upgrade" <button>
@if ($showProgress) @if ($showProgress)
<svg xmlns="http://www.w3.org/2000/svg" <svg xmlns="http://www.w3.org/2000/svg"
class="w-6 h-6 text-pink-500 transition-colors hover:text-pink-300 lds-heart" viewBox="0 0 24 24" class="w-6 h-6 text-pink-500 transition-colors hover:text-pink-300 lds-heart" viewBox="0 0 24 24"
@ -22,48 +22,6 @@
</svg> </svg>
@endif @endif
</button> </button>
<script>
let checkHealthInterval = null;
let checkIfIamDeadInterval = null;
function revive() {
console.log('Checking server\'s health...')
checkHealthInterval = setInterval(() => {
fetch('/api/health')
.then(response => {
if (response.ok) {
Toaster.success('Coolify is back online. Reloading...')
if (checkHealthInterval) clearInterval(checkHealthInterval);
setTimeout(() => {
window.location.reload();
}, 5000)
} else {
console.log('Waiting for server to come back from dead...');
}
})
return;
}, 2000);
}
function upgrade() {
console.log('Update initiated.')
checkIfIamDeadInterval = setInterval(() => {
fetch('/api/health')
.then(response => {
if (response.ok) {
console.log('It\'s alive. Waiting for server to be dead...');
} else {
Toaster.success('Update done, restarting Coolify!')
console.log('It\'s dead. Reviving... Standby... Bzz... Bzz...')
if (checkIfIamDeadInterval) clearInterval(checkIfIamDeadInterval);
revive();
}
})
return;
}, 2000);
}
</script>
</div> </div>
@endif @endif
</li> </li>