rector: arrrrr
This commit is contained in:
@@ -10,6 +10,7 @@ use Carbon\Carbon;
|
||||
use Illuminate\Process\InvokedProcess;
|
||||
use Illuminate\Support\Facades\Process;
|
||||
use Livewire\Component;
|
||||
use Throwable;
|
||||
|
||||
class Deploy extends Component
|
||||
{
|
||||
@@ -38,11 +39,7 @@ class Deploy extends Component
|
||||
|
||||
public function mount()
|
||||
{
|
||||
if ($this->server->id === 0) {
|
||||
$this->serverIp = base_ip();
|
||||
} else {
|
||||
$this->serverIp = $this->server->ip;
|
||||
}
|
||||
$this->serverIp = $this->server->id === 0 ? base_ip() : $this->server->ip;
|
||||
$this->currentRoute = request()->route()->getName();
|
||||
}
|
||||
|
||||
@@ -67,9 +64,11 @@ class Deploy extends Component
|
||||
try {
|
||||
$this->stop();
|
||||
$this->dispatch('checkProxy');
|
||||
} catch (\Throwable $e) {
|
||||
} catch (Throwable $e) {
|
||||
return handleError($e, $this);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function checkProxy()
|
||||
@@ -78,9 +77,11 @@ class Deploy extends Component
|
||||
CheckProxy::run($this->server, true);
|
||||
$this->dispatch('startProxyPolling');
|
||||
$this->dispatch('proxyChecked');
|
||||
} catch (\Throwable $e) {
|
||||
} catch (Throwable $e) {
|
||||
return handleError($e, $this);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function startProxy()
|
||||
@@ -90,9 +91,11 @@ class Deploy extends Component
|
||||
$this->server->save();
|
||||
$activity = StartProxy::run($this->server, force: true);
|
||||
$this->dispatch('activityMonitor', $activity->id, ProxyStatusChanged::class);
|
||||
} catch (\Throwable $e) {
|
||||
} catch (Throwable $e) {
|
||||
return handleError($e, $this);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function stop(bool $forceStop = true)
|
||||
@@ -114,7 +117,7 @@ class Deploy extends Component
|
||||
}
|
||||
|
||||
$this->removeContainer($containerName);
|
||||
} catch (\Throwable $e) {
|
||||
} catch (Throwable $e) {
|
||||
return handleError($e, $this);
|
||||
} finally {
|
||||
$this->server->proxy->force_stop = $forceStop;
|
||||
@@ -122,6 +125,8 @@ class Deploy extends Component
|
||||
$this->server->save();
|
||||
$this->dispatch('proxyStatusUpdated');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private function stopContainer(string $containerName, int $timeout): InvokedProcess
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Livewire\Server\Proxy;
|
||||
use App\Models\Server;
|
||||
use Illuminate\Support\Collection;
|
||||
use Livewire\Component;
|
||||
use Throwable;
|
||||
|
||||
class DynamicConfigurations extends Component
|
||||
{
|
||||
@@ -32,7 +33,7 @@ class DynamicConfigurations extends Component
|
||||
{
|
||||
$proxy_path = $this->server->proxyPath();
|
||||
$files = instant_remote_process(["mkdir -p $proxy_path/dynamic && ls -1 {$proxy_path}/dynamic"], $this->server);
|
||||
$files = collect(explode("\n", $files))->filter(fn ($file) => ! empty($file));
|
||||
$files = collect(explode("\n", $files))->reject(fn ($file): bool => $file === '' || $file === '0');
|
||||
$files = $files->map(fn ($file) => trim($file));
|
||||
$files = $files->sort();
|
||||
$contents = collect([]);
|
||||
@@ -52,9 +53,11 @@ class DynamicConfigurations extends Component
|
||||
if (is_null($this->server)) {
|
||||
return redirect()->route('server.index');
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
} catch (Throwable $e) {
|
||||
return handleError($e, $this);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function render()
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Livewire\Server\Proxy;
|
||||
|
||||
use App\Models\Server;
|
||||
use Livewire\Component;
|
||||
use Throwable;
|
||||
|
||||
class Logs extends Component
|
||||
{
|
||||
@@ -19,9 +20,11 @@ class Logs extends Component
|
||||
if (is_null($this->server)) {
|
||||
return redirect()->route('server.index');
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
} catch (Throwable $e) {
|
||||
return handleError($e, $this);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function render()
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Enums\ProxyTypes;
|
||||
use App\Models\Server;
|
||||
use Livewire\Component;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
use Throwable;
|
||||
|
||||
class NewDynamicConfiguration extends Component
|
||||
{
|
||||
@@ -53,7 +54,7 @@ class NewDynamicConfiguration extends Component
|
||||
if ($this->fileName === 'coolify.yaml') {
|
||||
$this->dispatch('error', 'File name is reserved.');
|
||||
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
} elseif ($proxy_type === 'CADDY') {
|
||||
if (! str($this->fileName)->endsWith('.caddy')) {
|
||||
@@ -67,7 +68,7 @@ class NewDynamicConfiguration extends Component
|
||||
if ($exists == 1) {
|
||||
$this->dispatch('error', 'File already exists');
|
||||
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if ($proxy_type === ProxyTypes::TRAEFIK->value) {
|
||||
@@ -85,9 +86,11 @@ class NewDynamicConfiguration extends Component
|
||||
$this->dispatch('loadDynamicConfigurations');
|
||||
$this->dispatch('dynamic-configuration-added');
|
||||
$this->dispatch('success', 'Dynamic configuration saved.');
|
||||
} catch (\Throwable $e) {
|
||||
} catch (Throwable $e) {
|
||||
return handleError($e, $this);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function render()
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Livewire\Server\Proxy;
|
||||
|
||||
use App\Models\Server;
|
||||
use Livewire\Component;
|
||||
use Throwable;
|
||||
|
||||
class Show extends Component
|
||||
{
|
||||
@@ -23,9 +24,11 @@ class Show extends Component
|
||||
$this->parameters = get_route_parameters();
|
||||
try {
|
||||
$this->server = Server::ownedByCurrentTeam()->whereUuid(request()->server_uuid)->firstOrFail();
|
||||
} catch (\Throwable $e) {
|
||||
} catch (Throwable $e) {
|
||||
return handleError($e, $this);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function render()
|
||||
|
||||
@@ -7,6 +7,7 @@ use App\Actions\Proxy\CheckProxy;
|
||||
use App\Actions\Proxy\StartProxy;
|
||||
use App\Models\Server;
|
||||
use Livewire\Component;
|
||||
use Throwable;
|
||||
|
||||
class Status extends Component
|
||||
{
|
||||
@@ -38,9 +39,11 @@ class Status extends Component
|
||||
if ($this->numberOfPolls >= 10) {
|
||||
$this->polling = false;
|
||||
$this->numberOfPolls = 0;
|
||||
$notification && $this->dispatch('error', 'Proxy is not running.');
|
||||
if ($notification) {
|
||||
$this->dispatch('error', 'Proxy is not running.');
|
||||
}
|
||||
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
$this->numberOfPolls++;
|
||||
}
|
||||
@@ -51,17 +54,25 @@ class Status extends Component
|
||||
$this->dispatch('proxyStatusUpdated');
|
||||
if ($this->server->proxy->status === 'running') {
|
||||
$this->polling = false;
|
||||
$notification && $this->dispatch('success', 'Proxy is running.');
|
||||
} elseif ($this->server->proxy->status === 'exited' and ! $this->server->proxy->force_stop) {
|
||||
$notification && $this->dispatch('error', 'Proxy has exited.');
|
||||
if ($notification) {
|
||||
$this->dispatch('success', 'Proxy is running.');
|
||||
}
|
||||
} elseif ($this->server->proxy->status === 'exited' && ! $this->server->proxy->force_stop) {
|
||||
if ($notification) {
|
||||
$this->dispatch('error', 'Proxy has exited.');
|
||||
}
|
||||
} elseif ($this->server->proxy->force_stop) {
|
||||
$notification && $this->dispatch('error', 'Proxy is stopped manually.');
|
||||
} else {
|
||||
$notification && $this->dispatch('error', 'Proxy is not running.');
|
||||
if ($notification) {
|
||||
$this->dispatch('error', 'Proxy is stopped manually.');
|
||||
}
|
||||
} elseif ($notification) {
|
||||
$this->dispatch('error', 'Proxy is not running.');
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
} catch (Throwable $e) {
|
||||
return handleError($e, $this);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getProxyStatus()
|
||||
@@ -70,8 +81,10 @@ class Status extends Component
|
||||
GetContainersStatus::run($this->server);
|
||||
// dispatch_sync(new ContainerStatusJob($this->server));
|
||||
$this->dispatch('proxyStatusUpdated');
|
||||
} catch (\Throwable $e) {
|
||||
} catch (Throwable $e) {
|
||||
return handleError($e, $this);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user