feat: Add manual update option to UpdateCoolify handle method

This commit is contained in:
Andras Bacsai 2024-05-30 19:38:33 +02:00
parent c839cf50af
commit 30a9783348
2 changed files with 15 additions and 13 deletions

View File

@ -14,7 +14,7 @@ class UpdateCoolify
public ?string $latestVersion = null; public ?string $latestVersion = null;
public ?string $currentVersion = null; public ?string $currentVersion = null;
public function handle() public function handle($manual_update = false)
{ {
try { try {
$settings = InstanceSettings::get(); $settings = InstanceSettings::get();
@ -26,6 +26,7 @@ class UpdateCoolify
CleanupDocker::run($this->server, false); CleanupDocker::run($this->server, false);
$this->latestVersion = get_latest_version_of_coolify(); $this->latestVersion = get_latest_version_of_coolify();
$this->currentVersion = config('version'); $this->currentVersion = config('version');
if (!$manual_update) {
if (!$settings->is_auto_update_enabled) { if (!$settings->is_auto_update_enabled) {
Log::debug('Auto update is disabled'); Log::debug('Auto update is disabled');
return; return;
@ -38,6 +39,7 @@ class UpdateCoolify
Log::debug('Latest version is lower than current version?!'); Log::debug('Latest version is lower than current version?!');
return; return;
} }
}
Log::info("Updating from {$this->currentVersion} -> {$this->latestVersion}"); Log::info("Updating from {$this->currentVersion} -> {$this->latestVersion}");
$this->update(); $this->update();
} catch (\Throwable $e) { } catch (\Throwable $e) {

View File

@ -33,7 +33,7 @@ class Upgrade extends Component
} }
$this->rateLimit(1, 60); $this->rateLimit(1, 60);
$this->updateInProgress = true; $this->updateInProgress = true;
UpdateCoolify::run(); UpdateCoolify::run(manual_update: true);
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} }