2023-05-15 11:45:37 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Jobs;
|
|
|
|
|
|
|
|
use App\Actions\Proxy\InstallProxy;
|
|
|
|
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');
|
|
|
|
$servers = Server::whereRelation('settings', 'is_validated', true)->get();
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|