lots of UI fixes

This commit is contained in:
Andras Bacsai
2023-07-14 13:38:24 +02:00
parent 2f613aed26
commit 8b128c1bbe
17 changed files with 188 additions and 145 deletions

View File

@@ -117,7 +117,7 @@ class ApplicationDeploymentJob implements ShouldQueue
} else {
$this->deploy();
}
if ($this->application->fqdn) dispatch(new ProxyCheckJob($this->server));
if ($this->application->fqdn) dispatch(new ProxyStartJob($this->server));
$this->next(ApplicationDeploymentStatus::FINISHED->value);
} catch (\Exception $e) {
ray($e);

View File

@@ -2,7 +2,7 @@
namespace App\Jobs;
use App\Actions\Proxy\InstallProxy;
use App\Actions\Proxy\StartProxy;
use App\Enums\ProxyTypes;
use App\Models\Server;
use Illuminate\Bus\Queueable;
@@ -15,30 +15,20 @@ class ProxyCheckJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public function __construct(protected Server|null $server = null)
public function __construct()
{
}
public function handle()
{
try {
$container_name = 'coolify-proxy';
if ($this->server) {
ray('Checking proxy for server: ' . $this->server->name);
$status = get_container_status(server: $this->server, container_id: $container_name);
$servers = Server::isUsable()->whereNotNull('proxy')->get();
foreach ($servers as $server) {
$status = get_container_status(server: $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) {
$status = get_container_status(server: $server, container_id: $container_name);
if ($status === 'running') {
continue;
}
resolve(InstallProxy::class)($server);
continue;
}
resolve(StartProxy::class)($server);
}
} catch (\Throwable $th) {
ray($th->getMessage());

35
app/Jobs/ProxyStartJob.php Executable file
View File

@@ -0,0 +1,35 @@
<?php
namespace App\Jobs;
use App\Actions\Proxy\StartProxy;
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;
class ProxyStartJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public function __construct(protected Server $server)
{
}
public function handle()
{
try {
$container_name = 'coolify-proxy';
ray('Starting proxy for server: ' . $this->server->name);
$status = get_container_status(server: $this->server, container_id: $container_name);
if ($status === 'running') {
return;
}
resolve(StartProxy::class)($this->server);
} catch (\Throwable $th) {
ray($th->getMessage());
//throw $th;
}
}
}