2023-05-15 11:45:37 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Jobs;
|
|
|
|
|
|
|
|
use App\Actions\Proxy\InstallProxy;
|
2023-05-26 07:45:18 +00:00
|
|
|
use App\Enums\ProxyTypes;
|
2023-05-15 11:45:37 +00: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 13:50:36 +00:00
|
|
|
class ProxyCheckJob implements ShouldQueue
|
2023-05-15 11:45:37 +00:00
|
|
|
{
|
|
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new job instance.
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the job.
|
|
|
|
*/
|
|
|
|
public function handle()
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
$container_name = 'coolify-proxy';
|
2023-06-30 09:42:59 +00:00
|
|
|
$servers = Server::whereRelation('settings', 'is_usable', true)->where('proxy->type', ProxyTypes::TRAEFIK_V2)->get();
|
2023-05-15 11:45:37 +00:00
|
|
|
|
|
|
|
foreach ($servers as $server) {
|
2023-05-24 12:26:50 +00:00
|
|
|
$status = get_container_status(server: $server, container_id: $container_name);
|
2023-05-15 11:45:37 +00:00
|
|
|
if ($status === 'running') {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
resolve(InstallProxy::class)($server);
|
|
|
|
}
|
|
|
|
} catch (\Throwable $th) {
|
|
|
|
//throw $th;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|