lasthourcloud/app/Jobs/PullHelperImageJob.php

48 lines
1.3 KiB
PHP
Raw Normal View History

<?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;
2024-06-10 20:43:34 +00:00
class PullHelperImageJob implements ShouldBeEncrypted, ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public $timeout = 1000;
public function middleware(): array
{
return [(new WithoutOverlapping($this->server->uuid))];
}
public function uniqueId(): string
{
return $this->server->uuid;
}
2024-06-10 20:43:34 +00:00
public function __construct(public Server $server)
{
}
2024-06-10 20:43:34 +00:00
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);
ray('PullHelperImageJob done');
} catch (\Throwable $e) {
2024-06-10 20:43:34 +00:00
send_internal_notification('PullHelperImageJob failed with: '.$e->getMessage());
ray($e->getMessage());
throw $e;
}
}
}