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.

fix: dockerimage jobs are not overlapping

Andras Bacsai8e86ce671cab
diff --git a/app/Actions/Server/UpdateCoolify.php b/app/Actions/Server/UpdateCoolify.php
index e988965ec2..de4700b753 100644
--- a/app/Actions/Server/UpdateCoolify.php
+++ b/app/Actions/Server/UpdateCoolify.php
@@ -7,9 +7,9 @@ use App\Models\Server;
class UpdateCoolify
{
- public Server $server;
- public string $latest_version;
- public string $current_version;
+ public ?Server $server = null;
+ public ?string $latestVersion = null;
+ public ?string $currentVersion = null;
public function __invoke(bool $force)
{
@@ -19,15 +19,14 @@ class UpdateCoolify
$localhost_name = 'localhost';
$this->server = Server::where('name', $localhost_name)->first();
if (!$this->server) {
- // No server found, so we are running on local docker container
return;
}
- $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: ' . $force);
+ $this->latestVersion = get_latest_version_of_coolify();
+ $this->currentVersion = config('version');
+ ray('latest version:' . $this->latestVersion . " current version: " . $this->currentVersion . ' force: ' . $force);
if ($settings->next_channel) {
ray('next channel enabled');
- $this->latest_version = 'next';
+ $this->latestVersion = 'next';
}
if ($force) {
$this->update();
@@ -35,15 +34,15 @@ class UpdateCoolify
if (!$settings->is_auto_update_enabled) {
return 'Auto update is disabled';
}
- if ($this->latest_version === $this->current_version) {
+ if ($this->latestVersion === $this->currentVersion) {
return 'Already on latest version';
}
- if (version_compare($this->latest_version, $this->current_version, '<')) {
+ if (version_compare($this->latestVersion, $this->currentVersion, '<')) {
return 'Latest version is lower than current version?!';
}
$this->update();
}
- send_internal_notification('InstanceAutoUpdateJob done to version: ' . $this->latest_version . ' from version: ' . $this->current_version);
+ send_internal_notification('InstanceAutoUpdateJob done to version: ' . $this->latestVersion . ' from version: ' . $this->currentVersion);
} catch (\Exception $th) {
ray('InstanceAutoUpdateJob failed');
ray($th->getMessage());
@@ -55,7 +54,7 @@ class UpdateCoolify
private function update()
{
if (isDev()) {
- ray("Running update on local docker container. Updating to $this->latest_version");
+ ray("Running update on local docker container. Updating to $this->latestVersion");
remote_process([
"sleep 10"
], $this->server);
@@ -65,7 +64,7 @@ class UpdateCoolify
ray('Running update on production server');
remote_process([
"curl -fsSL https://cdn.coollabs.io/coolify/upgrade.sh -o /data/coolify/source/upgrade.sh",
- "bash /data/coolify/source/upgrade.sh $this->latest_version"
+ "bash /data/coolify/source/upgrade.sh $this->latestVersion"
], $this->server);
return;
}
diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php
index ffedc6e72e..07032e1a16 100644
--- a/app/Console/Kernel.php
+++ b/app/Console/Kernel.php
@@ -25,7 +25,7 @@ class Kernel extends ConsoleKernel
$schedule->job(new CleanupInstanceStuffsJob)->everyMinute();
// $schedule->job(new CheckResaleLicenseJob)->hourly();
- // $schedule->job(new DockerCleanupJob)->everyOddHour();
+ $schedule->job(new DockerCleanupJob)->everyOddHour();
// $schedule->job(new InstanceAutoUpdateJob(true))->everyMinute();
} else {
$schedule->command('horizon:snapshot')->everyFiveMinutes();
diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php
index 5f24d4ab8e..715b22b91d 100644
--- a/app/Jobs/ApplicationDeploymentJob.php
+++ b/app/Jobs/ApplicationDeploymentJob.php
@@ -20,6 +20,7 @@ use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
+use Illuminate\Queue\Middleware\WithoutOverlapping;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Collection;
use Illuminate\Support\Str;
@@ -65,6 +66,12 @@ class ApplicationDeploymentJob implements ShouldQueue
private $log_model;
private Collection $saved_outputs;
+ public function middleware(): array
+ {
+ return [
+ (new WithoutOverlapping("dockerimagejobs"))->shared(),
+ ];
+ }
public function __construct(int $application_deployment_queue_id)
{
ray()->clearScreen();
diff --git a/app/Jobs/DockerCleanupJob.php b/app/Jobs/DockerCleanupJob.php
index 6ac00bc4b1..4456eee5e9 100644
--- a/app/Jobs/DockerCleanupJob.php
+++ b/app/Jobs/DockerCleanupJob.php
@@ -7,6 +7,7 @@ use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
+use Illuminate\Queue\Middleware\WithoutOverlapping;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Str;
@@ -17,6 +18,13 @@ class DockerCleanupJob implements ShouldQueue
public $timeout = 500;
public ?string $dockerRootFilesystem = null;
public ?int $usageBefore = null;
+
+ public function middleware(): array
+ {
+ return [
+ (new WithoutOverlapping("dockerimagejobs"))->shared(),
+ ];
+ }
public function __construct()
{
}