coolify/app/Jobs/ProxyCheckJob.php

40 lines
1.1 KiB
PHP
Raw Normal View History

2023-05-15 13:45:37 +02:00
<?php
namespace App\Jobs;
2023-07-14 13:38:24 +02:00
use App\Actions\Proxy\StartProxy;
2023-05-15 13:45:37 +02:00
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;
2023-07-07 15:50:36 +02:00
class ProxyCheckJob implements ShouldQueue
2023-05-15 13:45:37 +02:00
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
2023-07-14 13:38:24 +02:00
public function __construct()
2023-05-15 13:45:37 +02:00
{
}
2023-05-15 13:45:37 +02:00
public function handle()
{
try {
$container_name = 'coolify-proxy';
2023-07-14 13:38:24 +02:00
$servers = Server::isUsable()->whereNotNull('proxy')->get();
foreach ($servers as $server) {
$status = get_container_status(server: $server, container_id: $container_name);
2023-05-15 13:45:37 +02:00
if ($status === 'running') {
2023-07-14 13:38:24 +02:00
continue;
2023-05-15 13:45:37 +02:00
}
2023-07-26 15:20:04 +02:00
// $server->team->notify(new ProxyStoppedNotification($server));
2023-07-14 13:38:24 +02:00
resolve(StartProxy::class)($server);
2023-05-15 13:45:37 +02:00
}
} catch (\Throwable $th) {
ray($th->getMessage());
2023-05-15 13:45:37 +02:00
//throw $th;
}
}
}