lasthourcloud/app/Jobs/InstanceProxyCheckJob.php

47 lines
1.2 KiB
PHP
Raw Normal View History

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-05-24 12:26:50 +00:00
class InstanceProxyCheckJob 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';
$configuration_path = config('coolify.proxy_config_path');
2023-05-26 07:45:18 +00:00
$servers = Server::whereRelation('settings', 'is_validated', true)->where('extra_attributes->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;
}
}
}