From 70a4b7c863957872167e16082865833be2af6f7c Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 17 May 2024 09:52:19 +0200 Subject: [PATCH] feat: new manual update process + remove next_channel --- app/Actions/Server/UpdateCoolify.php | 8 +- app/Livewire/Settings/Configuration.php | 16 +- app/Livewire/Upgrade.php | 18 +- resources/views/components/navbar.blade.php | 21 +-- resources/views/layouts/base.blade.php | 41 ----- .../livewire/settings/configuration.blade.php | 6 +- resources/views/livewire/upgrade.blade.php | 160 +++++++++++++++--- 7 files changed, 167 insertions(+), 103 deletions(-) diff --git a/app/Actions/Server/UpdateCoolify.php b/app/Actions/Server/UpdateCoolify.php index c74072068..ac548a951 100644 --- a/app/Actions/Server/UpdateCoolify.php +++ b/app/Actions/Server/UpdateCoolify.php @@ -27,10 +27,10 @@ class UpdateCoolify CleanupDocker::run($this->server, false); $this->latestVersion = get_latest_version_of_coolify(); $this->currentVersion = config('version'); - if ($settings->next_channel) { - ray('next channel enabled'); - $this->latestVersion = 'next'; - } + // if ($settings->next_channel) { + // ray('next channel enabled'); + // $this->latestVersion = 'next'; + // } if ($force) { $this->update(); } else { diff --git a/app/Livewire/Settings/Configuration.php b/app/Livewire/Settings/Configuration.php index 5281a1e01..54dbe1bdb 100644 --- a/app/Livewire/Settings/Configuration.php +++ b/app/Livewire/Settings/Configuration.php @@ -13,7 +13,7 @@ class Configuration extends Component public bool $is_auto_update_enabled; public bool $is_registration_enabled; public bool $is_dns_validation_enabled; - public bool $next_channel; + // public bool $next_channel; protected string $dynamic_config_path = '/data/coolify/proxy/dynamic'; protected Server $server; @@ -37,7 +37,7 @@ class Configuration extends Component $this->do_not_track = $this->settings->do_not_track; $this->is_auto_update_enabled = $this->settings->is_auto_update_enabled; $this->is_registration_enabled = $this->settings->is_registration_enabled; - $this->next_channel = $this->settings->next_channel; + // $this->next_channel = $this->settings->next_channel; $this->is_dns_validation_enabled = $this->settings->is_dns_validation_enabled; } @@ -47,12 +47,12 @@ class Configuration extends Component $this->settings->is_auto_update_enabled = $this->is_auto_update_enabled; $this->settings->is_registration_enabled = $this->is_registration_enabled; $this->settings->is_dns_validation_enabled = $this->is_dns_validation_enabled; - if ($this->next_channel) { - $this->settings->next_channel = false; - $this->next_channel = false; - } else { - $this->settings->next_channel = $this->next_channel; - } + // if ($this->next_channel) { + // $this->settings->next_channel = false; + // $this->next_channel = false; + // } else { + // $this->settings->next_channel = $this->next_channel; + // } $this->settings->save(); $this->dispatch('success', 'Settings updated!'); } diff --git a/app/Livewire/Upgrade.php b/app/Livewire/Upgrade.php index 96ee76325..6af1e98db 100644 --- a/app/Livewire/Upgrade.php +++ b/app/Livewire/Upgrade.php @@ -3,7 +3,6 @@ namespace App\Livewire; use App\Actions\Server\UpdateCoolify; -use App\Models\InstanceSettings; use Livewire\Component; use DanHarrin\LivewireRateLimiting\WithRateLimiting; @@ -11,6 +10,7 @@ class Upgrade extends Component { use WithRateLimiting; public bool $showProgress = false; + public bool $updateInProgress = false; public bool $isUpgradeAvailable = false; public string $latestVersion = ''; @@ -19,26 +19,20 @@ class Upgrade extends Component $this->latestVersion = get_latest_version_of_coolify(); $currentVersion = config('version'); version_compare($currentVersion, $this->latestVersion, '<') ? $this->isUpgradeAvailable = true : $this->isUpgradeAvailable = false; - if (isDev()) { + // if (isDev()) { $this->isUpgradeAvailable = true; - } - $settings = InstanceSettings::get(); - if ($settings->next_channel) { - $this->isUpgradeAvailable = true; - $this->latestVersion = 'next'; - } + // } } public function upgrade() { try { - if ($this->showProgress) { + if ($this->updateInProgress) { return; } - $this->rateLimit(1, 30); - $this->showProgress = true; + $this->rateLimit(1, 60); + $this->updateInProgress = true; UpdateCoolify::run(force: true, async: true); - $this->dispatch('success', "Updating Coolify to {$this->latestVersion} version..."); } catch (\Throwable $e) { return handleError($e, $this); } diff --git a/resources/views/components/navbar.blade.php b/resources/views/components/navbar.blade.php index 66fa1bbf3..924625424 100644 --- a/resources/views/components/navbar.blade.php +++ b/resources/views/components/navbar.blade.php @@ -161,10 +161,11 @@ class="{{ request()->is('storages*') ? 'menu-item-active menu-item' : 'menu-item' }}" href="{{ route('storage.index') }}"> - - - - + + + + S3 Storages @@ -175,9 +176,11 @@ class="{{ request()->is('shared-variables*') ? 'menu-item-active menu-item' : 'menu-item' }}" href="{{ route('shared-variables.index') }}"> - - - + + + Shared Variables @@ -318,9 +321,7 @@
@if (isInstanceAdmin() && !isCloud())
  • - @persist('upgrade') - - @endpersist +
  • @endif
  • diff --git a/resources/views/layouts/base.blade.php b/resources/views/layouts/base.blade.php index 4d6f6596b..095def8a8 100644 --- a/resources/views/layouts/base.blade.php +++ b/resources/views/layouts/base.blade.php @@ -98,47 +98,6 @@ } } - function revive() { - if (checkHealthInterval) return true; - console.log('Checking server\'s health...') - checkHealthInterval = setInterval(() => { - fetch('/api/health') - .then(response => { - if (response.ok) { - window.toast('Coolify is back online. Reloading...', { - type: 'success', - }) - if (checkHealthInterval) clearInterval(checkHealthInterval); - setTimeout(() => { - window.location.reload(); - }, 5000) - } else { - console.log('Waiting for server to come back from dead...'); - } - }) - }, 2000); - } - - function upgrade() { - if (checkIfIamDeadInterval) return true; - 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 { - window.toast('Update done, restarting Coolify!', { - type: 'success', - }) - console.log('It\'s dead. Reviving... Standby... Bzz... Bzz...') - if (checkIfIamDeadInterval) clearInterval(checkIfIamDeadInterval); - revive(); - } - }) - }, 2000); - } - function copyToClipboard(text) { navigator?.clipboard?.writeText(text) && window.Livewire.dispatch('success', 'Copied to clipboard.'); } diff --git a/resources/views/livewire/settings/configuration.blade.php b/resources/views/livewire/settings/configuration.blade.php index 6c95bb4ac..efc1afc0a 100644 --- a/resources/views/livewire/settings/configuration.blade.php +++ b/resources/views/livewire/settings/configuration.blade.php @@ -9,7 +9,7 @@
    General configuration for your Coolify instance.
    -
    +
    - @if ($next_channel) + {{-- @if ($next_channel) @else - @endif + @endif --}}
    diff --git a/resources/views/livewire/upgrade.blade.php b/resources/views/livewire/upgrade.blade.php index 1e3ad014b..5ae58f98f 100644 --- a/resources/views/livewire/upgrade.blade.php +++ b/resources/views/livewire/upgrade.blade.php @@ -1,29 +1,139 @@
    + x-init="$wire.checkUpdate" x-data="upgradeModal"> @if ($isUpgradeAvailable) - +
    + + + +
    @endif
    + +