2023-10-26 09:38:37 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Jobs;
|
|
|
|
|
|
|
|
use App\Models\Server;
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
|
|
use Illuminate\Contracts\Queue\ShouldBeEncrypted;
|
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
|
|
use Illuminate\Queue\Middleware\WithoutOverlapping;
|
|
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
|
|
|
|
class PullHelperImageJob implements ShouldQueue, ShouldBeEncrypted
|
|
|
|
{
|
|
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
|
|
|
|
public $timeout = 1000;
|
|
|
|
|
|
|
|
public function middleware(): array
|
|
|
|
{
|
2024-01-18 12:33:57 +00:00
|
|
|
return [(new WithoutOverlapping($this->server->uuid))];
|
2023-10-26 09:38:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function uniqueId(): string
|
|
|
|
{
|
|
|
|
return $this->server->uuid;
|
|
|
|
}
|
|
|
|
public function __construct(public Server $server)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
public function handle(): void
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
$helperImage = config('coolify.helper_image');
|
|
|
|
ray("Pulling {$helperImage}");
|
2023-10-27 07:28:43 +00:00
|
|
|
instant_remote_process(["docker pull -q {$helperImage}"], $this->server, false);
|
2023-10-26 09:38:37 +00:00
|
|
|
ray('PullHelperImageJob done');
|
|
|
|
} catch (\Throwable $e) {
|
|
|
|
send_internal_notification('PullHelperImageJob failed with: ' . $e->getMessage());
|
|
|
|
ray($e->getMessage());
|
|
|
|
throw $e;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|