fix: autoupdater
This commit is contained in:
parent
3d3d31ef29
commit
43fed96af1
@ -12,10 +12,12 @@ 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)
|
public function handle(bool $force = false, bool $async = false)
|
||||||
{
|
{
|
||||||
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);
|
||||||
@ -56,17 +58,31 @@ class UpdateCoolify
|
|||||||
{
|
{
|
||||||
if (isDev()) {
|
if (isDev()) {
|
||||||
ray("Running update on local docker container. Updating to $this->latestVersion");
|
ray("Running update on local docker container. Updating to $this->latestVersion");
|
||||||
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');
|
ray('Update done');
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
ray('Running update on production server');
|
ray('Running update on production server');
|
||||||
remote_process([
|
if ($this->async) {
|
||||||
"curl -fsSL https://cdn.coollabs.io/coolify/upgrade.sh -o /data/coolify/source/upgrade.sh",
|
remote_process([
|
||||||
"bash /data/coolify/source/upgrade.sh $this->latestVersion"
|
"curl -fsSL https://cdn.coollabs.io/coolify/upgrade.sh -o /data/coolify/source/upgrade.sh",
|
||||||
], $this->server);
|
"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);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,6 @@ class InstanceAutoUpdateJob implements ShouldQueue, ShouldBeUnique, ShouldBeEncr
|
|||||||
|
|
||||||
public function handle(): void
|
public function handle(): void
|
||||||
{
|
{
|
||||||
UpdateCoolify::run($this->force);
|
UpdateCoolify::run(force: $this->force, async: false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,8 +37,8 @@ class Upgrade extends Component
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->showProgress = true;
|
$this->showProgress = true;
|
||||||
UpdateCoolify::run(true);
|
UpdateCoolify::run(force: true, async: true);
|
||||||
$this->dispatch('success', "Upgrading to {$this->latestVersion} version...");
|
$this->dispatch('success', "Updating Coolify to {$this->latestVersion} version...");
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return handleError($e, $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ function handleError(?Throwable $error = null, ?Livewire\Component $livewire = n
|
|||||||
ray($error);
|
ray($error);
|
||||||
if ($error instanceof TooManyRequestsException) {
|
if ($error instanceof TooManyRequestsException) {
|
||||||
if (isset($livewire)) {
|
if (isset($livewire)) {
|
||||||
return $livewire->dispatch('error', 'Too many requests. Please try again in {$error->secondsUntilAvailable} seconds.');
|
return $livewire->dispatch('error', "Too many requests. Please try again in {$error->secondsUntilAvailable} seconds.");
|
||||||
}
|
}
|
||||||
return "Too many requests. Please try again in {$error->secondsUntilAvailable} seconds.";
|
return "Too many requests. Please try again in {$error->secondsUntilAvailable} seconds.";
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user