fix: proxy status
fix: start proxy in case any dns set somewhere
This commit is contained in:
parent
48ad40dea2
commit
e9ba295a1e
@ -12,6 +12,7 @@ class InstallProxy
|
|||||||
{
|
{
|
||||||
public function __invoke(Server $server): Activity
|
public function __invoke(Server $server): Activity
|
||||||
{
|
{
|
||||||
|
// TODO: check for other proxies
|
||||||
if (is_null(data_get($server, 'proxy.type'))) {
|
if (is_null(data_get($server, 'proxy.type'))) {
|
||||||
$server->proxy->type = ProxyTypes::TRAEFIK_V2->value;
|
$server->proxy->type = ProxyTypes::TRAEFIK_V2->value;
|
||||||
$server->proxy->status = ProxyStatus::EXITED->value;
|
$server->proxy->status = ProxyStatus::EXITED->value;
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Livewire\Project\Application;
|
|
||||||
|
|
||||||
use App\Models\Application;
|
|
||||||
use Livewire\Component;
|
|
||||||
|
|
||||||
class Status extends Component
|
|
||||||
{
|
|
||||||
public Application $application;
|
|
||||||
|
|
||||||
public function applicationStatusChanged()
|
|
||||||
{
|
|
||||||
$this->application->refresh();
|
|
||||||
$this->emit('applicationStatusChanged');
|
|
||||||
}
|
|
||||||
}
|
|
@ -63,7 +63,7 @@ public function validateServer()
|
|||||||
} else {
|
} else {
|
||||||
$this->server->settings->is_usable = true;
|
$this->server->settings->is_usable = true;
|
||||||
$this->server->settings->save();
|
$this->server->settings->save();
|
||||||
$this->emit('serverValidated');
|
$this->emit('proxyStatusUpdated');
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->server->settings->is_reachable = false;
|
$this->server->settings->is_reachable = false;
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
namespace App\Http\Livewire\Server;
|
namespace App\Http\Livewire\Server;
|
||||||
|
|
||||||
use App\Actions\Proxy\CheckProxySettingsInSync;
|
use App\Actions\Proxy\CheckProxySettingsInSync;
|
||||||
use App\Actions\Proxy\InstallProxy;
|
|
||||||
use App\Enums\ProxyTypes;
|
use App\Enums\ProxyTypes;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
@ -17,12 +16,12 @@ class Proxy extends Component
|
|||||||
public $proxy_settings = null;
|
public $proxy_settings = null;
|
||||||
public string|null $redirect_url = null;
|
public string|null $redirect_url = null;
|
||||||
|
|
||||||
protected $listeners = ['serverValidated', 'saveConfiguration'];
|
protected $listeners = ['proxyStatusUpdated', 'saveConfiguration'];
|
||||||
public function mount()
|
public function mount()
|
||||||
{
|
{
|
||||||
$this->redirect_url = $this->server->proxy->redirect_url;
|
$this->redirect_url = $this->server->proxy->redirect_url;
|
||||||
}
|
}
|
||||||
public function serverValidated()
|
public function proxyStatusUpdated()
|
||||||
{
|
{
|
||||||
$this->server->refresh();
|
$this->server->refresh();
|
||||||
}
|
}
|
||||||
@ -44,7 +43,7 @@ public function stopProxy()
|
|||||||
], $this->server);
|
], $this->server);
|
||||||
$this->server->proxy->status = 'exited';
|
$this->server->proxy->status = 'exited';
|
||||||
$this->server->save();
|
$this->server->save();
|
||||||
$this->server->refresh();
|
$this->emit('proxyStatusUpdated');
|
||||||
}
|
}
|
||||||
public function saveConfiguration()
|
public function saveConfiguration()
|
||||||
{
|
{
|
||||||
|
@ -11,7 +11,7 @@ class Deploy extends Component
|
|||||||
{
|
{
|
||||||
public Server $server;
|
public Server $server;
|
||||||
public $proxy_settings = null;
|
public $proxy_settings = null;
|
||||||
protected $listeners = ['proxyStatusUpdated', 'serverValidated' => 'proxyStatusUpdated'];
|
protected $listeners = ['proxyStatusUpdated'];
|
||||||
public function proxyStatusUpdated()
|
public function proxyStatusUpdated()
|
||||||
{
|
{
|
||||||
$this->server->refresh();
|
$this->server->refresh();
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
class Status extends Component
|
class Status extends Component
|
||||||
{
|
{
|
||||||
public Server $server;
|
public Server $server;
|
||||||
protected $listeners = ['proxyStatusUpdated', 'serverValidated' => 'proxyStatusUpdated'];
|
protected $listeners = ['proxyStatusUpdated'];
|
||||||
public function proxyStatusUpdated()
|
public function proxyStatusUpdated()
|
||||||
{
|
{
|
||||||
$this->server->refresh();
|
$this->server->refresh();
|
||||||
@ -17,7 +17,7 @@ public function proxyStatusUpdated()
|
|||||||
public function proxyStatus()
|
public function proxyStatus()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
dispatch(new ProxyContainerStatusJob(
|
dispatch_sync(new ProxyContainerStatusJob(
|
||||||
server: $this->server
|
server: $this->server
|
||||||
));
|
));
|
||||||
$this->emit('proxyStatusUpdated');
|
$this->emit('proxyStatusUpdated');
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
namespace App\Http\Livewire\Settings;
|
namespace App\Http\Livewire\Settings;
|
||||||
|
|
||||||
|
use App\Actions\Proxy\InstallProxy;
|
||||||
use App\Jobs\ProxyCheckJob;
|
use App\Jobs\ProxyCheckJob;
|
||||||
use App\Models\InstanceSettings as ModelsInstanceSettings;
|
use App\Models\InstanceSettings as ModelsInstanceSettings;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use Illuminate\Support\Facades\Http;
|
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
use Spatie\Url\Url;
|
use Spatie\Url\Url;
|
||||||
use Symfony\Component\Yaml\Yaml;
|
use Symfony\Component\Yaml\Yaml;
|
||||||
@ -108,6 +108,7 @@ private function setup_instance_fqdn()
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
$this->save_configuration_to_disk($traefik_dynamic_conf, $file);
|
$this->save_configuration_to_disk($traefik_dynamic_conf, $file);
|
||||||
|
dispatch(new ProxyCheckJob($this->server));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private function save_configuration_to_disk(array $traefik_dynamic_conf, string $file)
|
private function save_configuration_to_disk(array $traefik_dynamic_conf, string $file)
|
||||||
@ -137,12 +138,8 @@ public function submit()
|
|||||||
}
|
}
|
||||||
$this->validate();
|
$this->validate();
|
||||||
$this->settings->save();
|
$this->settings->save();
|
||||||
|
|
||||||
$this->server = Server::findOrFail(0);
|
$this->server = Server::findOrFail(0);
|
||||||
$this->setup_instance_fqdn();
|
$this->setup_instance_fqdn();
|
||||||
if ($this->settings->fqdn) {
|
|
||||||
dispatch(new ProxyCheckJob());
|
|
||||||
}
|
|
||||||
$this->emit('success', 'Instance settings updated successfully!');
|
$this->emit('success', 'Instance settings updated successfully!');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,7 @@ public function __construct(int $application_deployment_queue_id)
|
|||||||
|
|
||||||
public function handle(): void
|
public function handle(): void
|
||||||
{
|
{
|
||||||
ray()->measure();
|
// ray()->measure();
|
||||||
$this->application_deployment_queue->update([
|
$this->application_deployment_queue->update([
|
||||||
'status' => ApplicationDeploymentStatus::IN_PROGRESS->value,
|
'status' => ApplicationDeploymentStatus::IN_PROGRESS->value,
|
||||||
]);
|
]);
|
||||||
@ -117,6 +117,7 @@ public function handle(): void
|
|||||||
} else {
|
} else {
|
||||||
$this->deploy();
|
$this->deploy();
|
||||||
}
|
}
|
||||||
|
if ($this->application->fqdn) dispatch(new ProxyCheckJob($this->server));
|
||||||
$this->next(ApplicationDeploymentStatus::FINISHED->value);
|
$this->next(ApplicationDeploymentStatus::FINISHED->value);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
ray($e);
|
ray($e);
|
||||||
@ -131,7 +132,7 @@ public function handle(): void
|
|||||||
"hidden" => true,
|
"hidden" => true,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
ray()->measure();
|
// ray()->measure();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function failed(Throwable $exception): void
|
public function failed(Throwable $exception): void
|
||||||
|
@ -15,21 +15,22 @@ class ProxyCheckJob implements ShouldQueue
|
|||||||
{
|
{
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
/**
|
public function __construct(protected Server|null $server)
|
||||||
* Create a new job instance.
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the job.
|
|
||||||
*/
|
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$container_name = 'coolify-proxy';
|
$container_name = 'coolify-proxy';
|
||||||
$servers = Server::whereRelation('settings', 'is_usable', true)->where('proxy->type', ProxyTypes::TRAEFIK_V2)->get();
|
if ($this->server) {
|
||||||
|
ray('Checking proxy for server: ' . $this->server->name);
|
||||||
|
$status = get_container_status(server: $this->server, container_id: $container_name);
|
||||||
|
if ($status === 'running') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
resolve(InstallProxy::class)($this->server);
|
||||||
|
} else {
|
||||||
|
$servers = Server::whereRelation('settings', 'is_usable', true)->get();
|
||||||
|
|
||||||
foreach ($servers as $server) {
|
foreach ($servers as $server) {
|
||||||
$status = get_container_status(server: $server, container_id: $container_name);
|
$status = get_container_status(server: $server, container_id: $container_name);
|
||||||
@ -38,7 +39,9 @@ public function handle()
|
|||||||
}
|
}
|
||||||
resolve(InstallProxy::class)($server);
|
resolve(InstallProxy::class)($server);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
|
ray($th->getMessage());
|
||||||
//throw $th;
|
//throw $th;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,10 @@ public function handle(): void
|
|||||||
$this->server->save();
|
$this->server->save();
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
ray($e->getMessage());
|
if ($e->getCode() === 1) {
|
||||||
|
$this->server->proxy->status = 'exited';
|
||||||
|
$this->server->save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ function instant_remote_process(array $command, Server $server, $throwError = tr
|
|||||||
if (!$throwError) {
|
if (!$throwError) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
throw new \RuntimeException($process->errorOutput());
|
throw new \RuntimeException($process->errorOutput(), $exitCode);
|
||||||
}
|
}
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
@ -25,10 +25,10 @@ public function run(): void
|
|||||||
'ip' => "coolify-testing-host",
|
'ip' => "coolify-testing-host",
|
||||||
'team_id' => $root_team->id,
|
'team_id' => $root_team->id,
|
||||||
'private_key_id' => $private_key_1->id,
|
'private_key_id' => $private_key_1->id,
|
||||||
'proxy' => ServerMetadata::from([
|
// 'proxy' => ServerMetadata::from([
|
||||||
'type' => ProxyTypes::TRAEFIK_V2->value,
|
// 'type' => ProxyTypes::TRAEFIK_V2->value,
|
||||||
'status' => ProxyStatus::EXITED->value
|
// 'status' => ProxyStatus::EXITED->value
|
||||||
]),
|
// ]),
|
||||||
]);
|
]);
|
||||||
Server::create([
|
Server::create([
|
||||||
'name' => "testing-local-docker-container-2",
|
'name' => "testing-local-docker-container-2",
|
||||||
|
@ -26,9 +26,11 @@
|
|||||||
]) }}">
|
]) }}">
|
||||||
<button>Destinations</button>
|
<button>Destinations</button>
|
||||||
</a>
|
</a>
|
||||||
|
@if ($server->settings->is_reachable)
|
||||||
@if (request()->routeIs('server.proxy'))
|
@if (request()->routeIs('server.proxy'))
|
||||||
<div class="flex-1"></div>
|
<div class="flex-1"></div>
|
||||||
<livewire:server.proxy.deploy :server="$server" />
|
<livewire:server.proxy.deploy :server="$server" />
|
||||||
@endif
|
@endif
|
||||||
|
@endif
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
<div wire:poll.10000ms='applicationStatusChanged'>
|
|
||||||
@if ($application->status === 'running')
|
|
||||||
<x-status.running />
|
|
||||||
@elseif($application->status === 'restarting')
|
|
||||||
<x-status.restarting />
|
|
||||||
@else
|
|
||||||
<x-status.stopped />
|
|
||||||
@endif
|
|
||||||
</div>
|
|
@ -12,7 +12,9 @@
|
|||||||
@if ($server->proxy->status === 'exited')
|
@if ($server->proxy->status === 'exited')
|
||||||
<x-forms.button wire:click.prevent="switchProxy">Switch Proxy</x-forms.button>
|
<x-forms.button wire:click.prevent="switchProxy">Switch Proxy</x-forms.button>
|
||||||
@endif
|
@endif
|
||||||
|
@if ($server->settings->is_reachable)
|
||||||
<livewire:server.proxy.status :server="$server" />
|
<livewire:server.proxy.status :server="$server" />
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="pt-3 pb-4 ">Traefik v2</div>
|
<div class="pt-3 pb-4 ">Traefik v2</div>
|
||||||
@ -23,11 +25,11 @@
|
|||||||
configs.
|
configs.
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
<x-forms.input placeholder="https://coolify.io" id="redirect_url" label="Default Redirect 404"
|
<div class="container w-full pb-4 mx-auto">
|
||||||
helper="All urls that has no service available will be redirected to this domain.<span class='text-helper'>You can set to your main marketing page or your social media link.</span>" />
|
|
||||||
<div class="container w-full mx-auto">
|
|
||||||
<livewire:activity-monitor :header="true" />
|
<livewire:activity-monitor :header="true" />
|
||||||
</div>
|
</div>
|
||||||
|
<x-forms.input placeholder="https://coolify.io" id="redirect_url" label="Default Redirect 404"
|
||||||
|
helper="All urls that has no service available will be redirected to this domain.<span class='text-helper'>You can set to your main marketing page or your social media link.</span>" />
|
||||||
<div wire:loading wire:target="checkProxySettingsInSync" class="pt-4">
|
<div wire:loading wire:target="checkProxySettingsInSync" class="pt-4">
|
||||||
<x-loading text="Loading proxy configuration..." />
|
<x-loading text="Loading proxy configuration..." />
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
<div>
|
<div>
|
||||||
@if ($server->settings->is_reachable)
|
|
||||||
@if ($server->proxy->status === 'running')
|
@if ($server->proxy->status === 'running')
|
||||||
<div class="flex gap-4">
|
<div class="flex gap-4">
|
||||||
<div class="group">
|
<div class="group">
|
||||||
@ -67,13 +66,11 @@ class="relative text-xs text-white normal-case rounded min-w-max menu bg-coolgra
|
|||||||
</div>
|
</div>
|
||||||
@else
|
@else
|
||||||
<button wire:click='deploy' class="flex items-center gap-2 cursor-pointer hover:text-white">
|
<button wire:click='deploy' class="flex items-center gap-2 cursor-pointer hover:text-white">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5 text-warning" viewBox="0 0 24 24"
|
<svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5 text-warning" viewBox="0 0 24 24" stroke-width="1.5"
|
||||||
stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round"
|
stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
||||||
stroke-linejoin="round">
|
|
||||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||||
<path d="M7 4v16l13 -8z" />
|
<path d="M7 4v16l13 -8z" />
|
||||||
</svg>Start Proxy
|
</svg>Start Proxy
|
||||||
</button>
|
</button>
|
||||||
@endif
|
@endif
|
||||||
@endif
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
<div>
|
|
||||||
@if ($server->settings->is_reachable)
|
|
||||||
<div wire:poll.10000ms="proxyStatus" x-init="$wire.proxyStatus">
|
<div wire:poll.10000ms="proxyStatus" x-init="$wire.proxyStatus">
|
||||||
@if ($server->proxy->status === 'running')
|
@if ($server->proxy->status === 'running')
|
||||||
<x-status.running />
|
<x-status.running />
|
||||||
@ -9,5 +7,3 @@
|
|||||||
<x-status.stopped />
|
<x-status.stopped />
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
@endif
|
|
||||||
</div>
|
|
||||||
|
Loading…
Reference in New Issue
Block a user