fix: test new upgrade process?
This commit is contained in:
parent
10d38b709b
commit
397b7fefe3
@ -5,6 +5,7 @@
|
|||||||
use Lorisleiva\Actions\Concerns\AsAction;
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
use App\Models\InstanceSettings;
|
use App\Models\InstanceSettings;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
class UpdateCoolify
|
class UpdateCoolify
|
||||||
{
|
{
|
||||||
@ -12,12 +13,10 @@ class UpdateCoolify
|
|||||||
public ?Server $server = null;
|
public ?Server $server = null;
|
||||||
public ?string $latestVersion = null;
|
public ?string $latestVersion = null;
|
||||||
public ?string $currentVersion = null;
|
public ?string $currentVersion = null;
|
||||||
public bool $async = false;
|
|
||||||
|
|
||||||
public function handle(bool $force = false, bool $async = false)
|
public function handle()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$this->async = $async;
|
|
||||||
$settings = InstanceSettings::get();
|
$settings = InstanceSettings::get();
|
||||||
ray('Running InstanceAutoUpdateJob');
|
ray('Running InstanceAutoUpdateJob');
|
||||||
$this->server = Server::find(0);
|
$this->server = Server::find(0);
|
||||||
@ -27,24 +26,20 @@ public function handle(bool $force = false, bool $async = false)
|
|||||||
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 ($settings->next_channel) {
|
if (!$settings->is_auto_update_enabled) {
|
||||||
// ray('next channel enabled');
|
Log::info('Auto update is disabled');
|
||||||
// $this->latestVersion = 'next';
|
throw 'Auto update is disabled';
|
||||||
// }
|
|
||||||
if ($force) {
|
|
||||||
$this->update();
|
|
||||||
} else {
|
|
||||||
if (!$settings->is_auto_update_enabled) {
|
|
||||||
return 'Auto update is disabled';
|
|
||||||
}
|
|
||||||
if ($this->latestVersion === $this->currentVersion) {
|
|
||||||
return 'Already on latest version';
|
|
||||||
}
|
|
||||||
if (version_compare($this->latestVersion, $this->currentVersion, '<')) {
|
|
||||||
return 'Latest version is lower than current version?!';
|
|
||||||
}
|
|
||||||
$this->update();
|
|
||||||
}
|
}
|
||||||
|
if ($this->latestVersion === $this->currentVersion) {
|
||||||
|
Log::info('Already on latest version');
|
||||||
|
throw 'Already on latest version';
|
||||||
|
}
|
||||||
|
if (version_compare($this->latestVersion, $this->currentVersion, '<')) {
|
||||||
|
Log::info('Latest version is lower than current version?!');
|
||||||
|
throw 'Latest version is lower than current version?!';
|
||||||
|
}
|
||||||
|
Log::info("Updating from {$this->currentVersion} -> {$this->latestVersion}");
|
||||||
|
$this->update();
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
ray('InstanceAutoUpdateJob failed');
|
ray('InstanceAutoUpdateJob failed');
|
||||||
ray($e->getMessage());
|
ray($e->getMessage());
|
||||||
@ -56,34 +51,16 @@ public function handle(bool $force = false, bool $async = false)
|
|||||||
private function update()
|
private function update()
|
||||||
{
|
{
|
||||||
if (isDev()) {
|
if (isDev()) {
|
||||||
ray("Running update on local docker container. Updating to $this->latestVersion");
|
instant_remote_process([
|
||||||
if ($this->async) {
|
"sleep 10"
|
||||||
ray('Running async update');
|
], $this->server);
|
||||||
remote_process([
|
|
||||||
"sleep 10"
|
|
||||||
], $this->server);
|
|
||||||
} else {
|
|
||||||
instant_remote_process([
|
|
||||||
"sleep 10"
|
|
||||||
], $this->server);
|
|
||||||
}
|
|
||||||
ray('Update done');
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
ray('Running update on production server');
|
|
||||||
if ($this->async) {
|
|
||||||
remote_process([
|
|
||||||
"curl -fsSL https://cdn.coollabs.io/coolify/upgrade.sh -o /data/coolify/source/upgrade.sh",
|
|
||||||
"bash /data/coolify/source/upgrade.sh $this->latestVersion"
|
|
||||||
], $this->server);
|
|
||||||
} else {
|
|
||||||
instant_remote_process([
|
|
||||||
"curl -fsSL https://cdn.coollabs.io/coolify/upgrade.sh -o /data/coolify/source/upgrade.sh",
|
|
||||||
"bash /data/coolify/source/upgrade.sh $this->latestVersion"
|
|
||||||
], $this->server);
|
|
||||||
}
|
|
||||||
send_internal_notification("Instance updated from {$this->currentVersion} -> {$this->latestVersion}");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
instant_remote_process([
|
||||||
|
"curl -fsSL https://cdn.coollabs.io/coolify/upgrade.sh -o /data/coolify/source/upgrade.sh",
|
||||||
|
"bash /data/coolify/source/upgrade.sh $this->latestVersion"
|
||||||
|
], $this->server);
|
||||||
|
send_internal_notification("Instance updated from {$this->currentVersion} -> {$this->latestVersion}");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,12 +18,12 @@ class InstanceAutoUpdateJob implements ShouldQueue, ShouldBeUnique, ShouldBeEncr
|
|||||||
public $timeout = 600;
|
public $timeout = 600;
|
||||||
public $tries = 1;
|
public $tries = 1;
|
||||||
|
|
||||||
public function __construct(private bool $force = false)
|
public function __construct()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handle(): void
|
public function handle(): void
|
||||||
{
|
{
|
||||||
UpdateCoolify::run(force: $this->force, async: false);
|
UpdateCoolify::run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ public function upgrade()
|
|||||||
}
|
}
|
||||||
$this->rateLimit(1, 60);
|
$this->rateLimit(1, 60);
|
||||||
$this->updateInProgress = true;
|
$this->updateInProgress = true;
|
||||||
UpdateCoolify::run(force: true, async: false);
|
UpdateCoolify::run();
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return handleError($e, $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user