fix: dockerimage jobs are not overlapping
This commit is contained in:
@@ -7,9 +7,9 @@ use App\Models\Server;
|
|||||||
|
|
||||||
class UpdateCoolify
|
class UpdateCoolify
|
||||||
{
|
{
|
||||||
public Server $server;
|
public ?Server $server = null;
|
||||||
public string $latest_version;
|
public ?string $latestVersion = null;
|
||||||
public string $current_version;
|
public ?string $currentVersion = null;
|
||||||
|
|
||||||
public function __invoke(bool $force)
|
public function __invoke(bool $force)
|
||||||
{
|
{
|
||||||
@@ -19,15 +19,14 @@ class UpdateCoolify
|
|||||||
$localhost_name = 'localhost';
|
$localhost_name = 'localhost';
|
||||||
$this->server = Server::where('name', $localhost_name)->first();
|
$this->server = Server::where('name', $localhost_name)->first();
|
||||||
if (!$this->server) {
|
if (!$this->server) {
|
||||||
// No server found, so we are running on local docker container
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->latest_version = get_latest_version_of_coolify();
|
$this->latestVersion = get_latest_version_of_coolify();
|
||||||
$this->current_version = config('version');
|
$this->currentVersion = config('version');
|
||||||
ray('latest version:' . $this->latest_version . " current version: " . $this->current_version . ' force: ' . $force);
|
ray('latest version:' . $this->latestVersion . " current version: " . $this->currentVersion . ' force: ' . $force);
|
||||||
if ($settings->next_channel) {
|
if ($settings->next_channel) {
|
||||||
ray('next channel enabled');
|
ray('next channel enabled');
|
||||||
$this->latest_version = 'next';
|
$this->latestVersion = 'next';
|
||||||
}
|
}
|
||||||
if ($force) {
|
if ($force) {
|
||||||
$this->update();
|
$this->update();
|
||||||
@@ -35,15 +34,15 @@ class UpdateCoolify
|
|||||||
if (!$settings->is_auto_update_enabled) {
|
if (!$settings->is_auto_update_enabled) {
|
||||||
return 'Auto update is disabled';
|
return 'Auto update is disabled';
|
||||||
}
|
}
|
||||||
if ($this->latest_version === $this->current_version) {
|
if ($this->latestVersion === $this->currentVersion) {
|
||||||
return 'Already on latest version';
|
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?!';
|
return 'Latest version is lower than current version?!';
|
||||||
}
|
}
|
||||||
$this->update();
|
$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) {
|
} catch (\Exception $th) {
|
||||||
ray('InstanceAutoUpdateJob failed');
|
ray('InstanceAutoUpdateJob failed');
|
||||||
ray($th->getMessage());
|
ray($th->getMessage());
|
||||||
@@ -55,7 +54,7 @@ class UpdateCoolify
|
|||||||
private function update()
|
private function update()
|
||||||
{
|
{
|
||||||
if (isDev()) {
|
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([
|
remote_process([
|
||||||
"sleep 10"
|
"sleep 10"
|
||||||
], $this->server);
|
], $this->server);
|
||||||
@@ -65,7 +64,7 @@ class UpdateCoolify
|
|||||||
ray('Running update on production server');
|
ray('Running update on production server');
|
||||||
remote_process([
|
remote_process([
|
||||||
"curl -fsSL https://cdn.coollabs.io/coolify/upgrade.sh -o /data/coolify/source/upgrade.sh",
|
"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);
|
], $this->server);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class Kernel extends ConsoleKernel
|
|||||||
$schedule->job(new CleanupInstanceStuffsJob)->everyMinute();
|
$schedule->job(new CleanupInstanceStuffsJob)->everyMinute();
|
||||||
|
|
||||||
// $schedule->job(new CheckResaleLicenseJob)->hourly();
|
// $schedule->job(new CheckResaleLicenseJob)->hourly();
|
||||||
// $schedule->job(new DockerCleanupJob)->everyOddHour();
|
$schedule->job(new DockerCleanupJob)->everyOddHour();
|
||||||
// $schedule->job(new InstanceAutoUpdateJob(true))->everyMinute();
|
// $schedule->job(new InstanceAutoUpdateJob(true))->everyMinute();
|
||||||
} else {
|
} else {
|
||||||
$schedule->command('horizon:snapshot')->everyFiveMinutes();
|
$schedule->command('horizon:snapshot')->everyFiveMinutes();
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ use Illuminate\Bus\Queueable;
|
|||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\Middleware\WithoutOverlapping;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
@@ -65,6 +66,12 @@ class ApplicationDeploymentJob implements ShouldQueue
|
|||||||
private $log_model;
|
private $log_model;
|
||||||
private Collection $saved_outputs;
|
private Collection $saved_outputs;
|
||||||
|
|
||||||
|
public function middleware(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
(new WithoutOverlapping("dockerimagejobs"))->shared(),
|
||||||
|
];
|
||||||
|
}
|
||||||
public function __construct(int $application_deployment_queue_id)
|
public function __construct(int $application_deployment_queue_id)
|
||||||
{
|
{
|
||||||
ray()->clearScreen();
|
ray()->clearScreen();
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use Illuminate\Bus\Queueable;
|
|||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\Middleware\WithoutOverlapping;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
@@ -17,6 +18,13 @@ class DockerCleanupJob implements ShouldQueue
|
|||||||
public $timeout = 500;
|
public $timeout = 500;
|
||||||
public ?string $dockerRootFilesystem = null;
|
public ?string $dockerRootFilesystem = null;
|
||||||
public ?int $usageBefore = null;
|
public ?int $usageBefore = null;
|
||||||
|
|
||||||
|
public function middleware(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
(new WithoutOverlapping("dockerimagejobs"))->shared(),
|
||||||
|
];
|
||||||
|
}
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user