fix: make sure proxy wont start in NONE mode

This commit is contained in:
Andras Bacsai 2023-10-12 08:51:32 +02:00
parent 6aca2740fb
commit a2f4d4ed6d
4 changed files with 10 additions and 5 deletions

View File

@ -2,6 +2,7 @@
namespace App\Actions\Proxy; namespace App\Actions\Proxy;
use App\Enums\ProxyTypes;
use App\Models\Server; use App\Models\Server;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Lorisleiva\Actions\Concerns\AsAction; use Lorisleiva\Actions\Concerns\AsAction;
@ -14,7 +15,7 @@ class StartProxy
{ {
$commands = collect([]); $commands = collect([]);
$proxyType = $server->proxyType(); $proxyType = $server->proxyType();
if ($proxyType === 'none') { if ($proxyType === ProxyTypes::NONE->value) {
return 'OK'; return 'OK';
} }
$proxy_path = get_proxy_path(); $proxy_path = get_proxy_path();

View File

@ -114,7 +114,6 @@ class ContainerStatusJob implements ShouldQueue, ShouldBeEncrypted
return data_get($value, 'Name') === '/coolify-proxy'; return data_get($value, 'Name') === '/coolify-proxy';
})->first(); })->first();
if (!$foundProxyContainer) { if (!$foundProxyContainer) {
ray('Proxy not found, starting it...');
if ($this->server->isProxyShouldRun()) { if ($this->server->isProxyShouldRun()) {
StartProxy::run($this->server, false); StartProxy::run($this->server, false);
$this->server->team->notify(new ContainerRestarted('coolify-proxy', $this->server)); $this->server->team->notify(new ContainerRestarted('coolify-proxy', $this->server));

View File

@ -93,8 +93,11 @@ class Server extends BaseModel
public function proxyType() public function proxyType()
{ {
$type = $this->proxy->get('type'); $proxyType = $this->proxy->get('type');
if (is_null($type)) { if ($proxyType === ProxyTypes::NONE->value) {
return $proxyType;
}
if (is_null($proxyType)) {
$this->proxy->type = ProxyTypes::TRAEFIK_V2->value; $this->proxy->type = ProxyTypes::TRAEFIK_V2->value;
$this->proxy->status = ProxyStatus::EXITED->value; $this->proxy->status = ProxyStatus::EXITED->value;
$this->save(); $this->save();

View File

@ -2,7 +2,9 @@
<livewire:server.proxy.modal :server="$server" /> <livewire:server.proxy.modal :server="$server" />
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<h1>Server</h1> <h1>Server</h1>
@if ($server->proxyType() !== 'NONE')
<livewire:server.proxy.status :server="$server" /> <livewire:server.proxy.status :server="$server" />
@endif
</div> </div>
<div class="subtitle ">{{ data_get($server, 'name') }}</div> <div class="subtitle ">{{ data_get($server, 'name') }}</div>
<nav class="navbar-main"> <nav class="navbar-main">