lasthourcloud/app/Jobs/ProxyStartJob.php

38 lines
1.0 KiB
PHP
Raw Normal View History

2023-07-14 13:38:24 +02:00
<?php
namespace App\Jobs;
use App\Actions\Proxy\StartProxy;
use App\Models\Server;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class ProxyStartJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public function __construct(protected Server $server)
{
}
2023-07-14 13:38:24 +02:00
public function handle()
{
try {
$container_name = 'coolify-proxy';
ray('Starting proxy for server: ' . $this->server->name);
2023-08-21 18:00:12 +02:00
$status = getContainerStatus(server: $this->server, container_id: $container_name);
2023-07-14 13:38:24 +02:00
if ($status === 'running') {
return;
}
resolve(StartProxy::class)($this->server);
} catch (\Throwable $th) {
2023-08-24 16:14:09 +02:00
send_internal_notification('ProxyStartJob failed with: ' . $th->getMessage());
2023-07-14 13:38:24 +02:00
ray($th->getMessage());
2023-08-24 21:09:58 +02:00
throw $th;
2023-07-14 13:38:24 +02:00
}
}
}