Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fixes

Andras Bacsai2014183e8815
diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php
index eda379d82b..f7c0778af3 100644
--- a/app/Console/Kernel.php
+++ b/app/Console/Kernel.php
@@ -10,21 +10,18 @@ use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
- /**
- * Define the application's command schedule.
- */
protected function schedule(Schedule $schedule): void
{
- $schedule->command('horizon:snapshot')->everyFiveMinutes();
-
- $schedule->job(new InstanceDockerCleanupJob)->everyFiveMinutes();
- $schedule->job(new InstanceAutoUpdateJob)->everyFifteenMinutes();
- // $schedule->job(new InstanceProxyCheckJob)->everyMinute();
+ if (config('app.env') === 'local') {
+ $schedule->command('horizon:snapshot')->everyMinute();
+ $schedule->job(new InstanceDockerCleanupJob)->everyMinute();
+ $schedule->job(new InstanceAutoUpdateJob(true))->everyMinute();
+ } else {
+ $schedule->command('horizon:snapshot')->everyFiveMinutes();
+ $schedule->job(new InstanceDockerCleanupJob)->everyFiveMinutes();
+ $schedule->job(new InstanceAutoUpdateJob)->everyFifteenMinutes();
+ }
}
-
- /**
- * Register the commands for the application.
- */
protected function commands(): void
{
$this->load(__DIR__ . '/Commands');
diff --git a/app/Jobs/InstanceAutoUpdateJob.php b/app/Jobs/InstanceAutoUpdateJob.php
index c97b370b46..4a34f457b7 100644
--- a/app/Jobs/InstanceAutoUpdateJob.php
+++ b/app/Jobs/InstanceAutoUpdateJob.php
@@ -18,6 +18,11 @@ class InstanceAutoUpdateJob implements ShouldQueue, ShouldBeUnique
public $tries = 1;
public $timeout = 120;
+
+ public Server $server;
+ public string $latest_version;
+ public string $current_version;
+
public function uniqueId(): int
{
return 1;
@@ -25,47 +30,56 @@ class InstanceAutoUpdateJob implements ShouldQueue, ShouldBeUnique
public function __construct(private bool $force = false)
{
}
-
+ private function update()
+ {
+ if (config('app.env') === 'local') {
+ ray('Running update on local docker container');
+ instant_remote_process([
+ "sleep 10"
+ ], $this->server);
+ ray('Update done');
+ return;
+ } else {
+ ray('Running update on production server');
+ instant_remote_process([
+ "curl -fsSL https://coolify-cdn.b-cdn.net/files/upgrade.sh -o /data/coolify/source/upgrade.sh",
+ "bash /data/coolify/source/upgrade.sh $this->latest_version"
+ ], $this->server);
+ return;
+ }
+ }
public function handle(): void
{
try {
+ ray('Running InstanceAutoUpdateJob');
$localhost_name = 'localhost';
if (config('app.env') === 'local') {
$localhost_name = 'testing-local-docker-container';
}
- $server = Server::where('name', $localhost_name)->firstOrFail();
- $latest_version = get_latest_version_of_coolify();
- $current_version = config('version');
-
- if (config('app.env') === 'local') {
- instant_remote_process([
- "sleep 10"
- ], $server);
- return;
+ $this->server = Server::where('name', $localhost_name)->firstOrFail();
+ $this->latest_version = get_latest_version_of_coolify();
+ $this->current_version = config('version');
+ ray('latest version:' . $this->latest_version . " current version: " . $this->current_version . ' force: ' . $this->force);
+ if ($this->force) {
+ $this->update();
} else {
- if (!$this->force) {
- $instance_settings = InstanceSettings::get();
- if (!$instance_settings->is_auto_update_enabled) {
- $this->fail('Auto update is disabled');
- return;
- }
- if ($latest_version === $current_version) {
- $this->fail("Already on latest version");
- return;
- }
- if (version_compare($latest_version, $current_version, '<')) {
- $this->fail("Latest version is lower than current version?!");
- return;
- }
+ $instance_settings = InstanceSettings::get();
+ ray($instance_settings);
+ if (!$instance_settings->is_auto_update_enabled) {
+ throw new \Exception('Auto update is disabled');
}
- instant_remote_process([
- "curl -fsSL https://coolify-cdn.b-cdn.net/files/upgrade.sh -o /data/coolify/source/upgrade.sh",
- "bash /data/coolify/source/upgrade.sh $latest_version"
- ], $server);
- return;
+ if ($this->latest_version === $this->current_version) {
+ throw new \Exception('Already on latest version');
+ }
+ if (version_compare($this->latest_version, $this->current_version, '<')) {
+ throw new \Exception('Latest version is lower than current version?!');
+ }
+ $this->update();
}
+ return;
} catch (\Exception $e) {
- Log::error($e->getMessage());
+ ray('InstanceAutoUpdateJob failed');
+ ray($e->getMessage());
$this->fail($e->getMessage());
return;
}
diff --git a/resources/css/app.css b/resources/css/app.css
index df2a15c2ac..088291967c 100644
--- a/resources/css/app.css
+++ b/resources/css/app.css
@@ -47,9 +47,6 @@ select {
@apply w-4 text-warning;
}
-button[type="submit"] {
- @apply hover:bg-coolgray-400 btn h-7 btn-xs border-none bg-coolgray-200 no-animation normal-case text-white rounded;
-}
button[isWarning] {
@apply bg-error hover:bg-error;
}
diff --git a/resources/views/components/forms/button.blade.php b/resources/views/components/forms/button.blade.php
index 6147da68da..efa7d96444 100644
--- a/resources/views/components/forms/button.blade.php
+++ b/resources/views/components/forms/button.blade.php
@@ -9,7 +9,9 @@
<div class="tooltip tooltip-warning" data-tip="{{ $tooltip }}">
@endisset
@if ($type === 'submit')
- <button {{ $attributes }} type="submit" @if ($disabled !== null) disabled @endif
+ <button
+ {{ $attributes->class(['btn btn-xs border-none no-animation normal-case text-white rounded', 'hover:bg-coolgray-400 bg-coolgray-200 h-7' => !$attributes->has('class')]) }}
+ type="submit" @if ($disabled !== null) disabled @endif
@isset($confirm)
x-on:click="toggleConfirmModal('{{ $confirm }}', '{{ explode('(', $confirmAction)[0] }}')"
@endisset
diff --git a/resources/views/livewire/activity-monitor.blade.php b/resources/views/livewire/activity-monitor.blade.php
index fead78e756..f900a4ae27 100644
--- a/resources/views/livewire/activity-monitor.blade.php
+++ b/resources/views/livewire/activity-monitor.blade.php
@@ -1,7 +1,7 @@
<div>
@if ($this->activity)
@if ($header)
- <div class="flex gap-2">
+ <div class="flex gap-2 pb-2">
<h2>Logs</h2>
@if ($isPollingActive)
<x-loading />
diff --git a/resources/views/livewire/run-command.blade.php b/resources/views/livewire/run-command.blade.php
index ea7da091a6..933bb9fbb5 100755
--- a/resources/views/livewire/run-command.blade.php
+++ b/resources/views/livewire/run-command.blade.php
@@ -12,9 +12,10 @@
@endif
@endforeach
</x-forms.select>
- <x-forms.button class="h-8" type="submit">Run</x-forms.button>
+ <x-forms.button type="submit" class="h-8 hover:bg-coolgray-400 bg-coolgray-200">Execute Command
+ </x-forms.button>
</form>
<div class="container w-full pt-10 mx-auto">
- <livewire:activity-monitor />
+ <livewire:activity-monitor :header="true" />
</div>
</div>