Fix styling

This commit is contained in:
andrasbacsai 2024-06-18 14:43:18 +00:00 committed by github-actions[bot]
parent 23ed697b98
commit ce15f8f1dd
8 changed files with 39 additions and 27 deletions

View File

@ -36,7 +36,7 @@ class PullSentinelImageJob implements ShouldBeEncrypted, ShouldQueue
{ {
try { try {
$version = get_latest_sentinel_version(); $version = get_latest_sentinel_version();
if (!$version) { if (! $version) {
ray('Failed to get latest Sentinel version'); ray('Failed to get latest Sentinel version');
return; return;
@ -47,11 +47,12 @@ class PullSentinelImageJob implements ShouldBeEncrypted, ShouldQueue
} }
if (version_compare($local_version, $version, '<')) { if (version_compare($local_version, $version, '<')) {
StartSentinel::run($this->server, $version, true); StartSentinel::run($this->server, $version, true);
return; return;
} }
ray('Sentinel image is up to date'); ray('Sentinel image is up to date');
} catch (\Throwable $e) { } catch (\Throwable $e) {
send_internal_notification('PullSentinelImageJob failed with: ' . $e->getMessage()); send_internal_notification('PullSentinelImageJob failed with: '.$e->getMessage());
ray($e->getMessage()); ray($e->getMessage());
throw $e; throw $e;
} }

View File

@ -41,7 +41,7 @@ class ServerStatusJob implements ShouldBeEncrypted, ShouldQueue
public function handle() public function handle()
{ {
if (!$this->server->isServerReady($this->tries)) { if (! $this->server->isServerReady($this->tries)) {
throw new \RuntimeException('Server is not ready.'); throw new \RuntimeException('Server is not ready.');
} }
try { try {
@ -53,7 +53,7 @@ class ServerStatusJob implements ShouldBeEncrypted, ShouldQueue
} }
} }
} catch (\Throwable $e) { } catch (\Throwable $e) {
send_internal_notification('ServerStatusJob failed with: ' . $e->getMessage()); send_internal_notification('ServerStatusJob failed with: '.$e->getMessage());
ray($e->getMessage()); ray($e->getMessage());
return handleError($e); return handleError($e);
@ -103,7 +103,7 @@ class ServerStatusJob implements ShouldBeEncrypted, ShouldQueue
{ {
// This will remote the coolify.yaml file from the server as it is not needed on cloud servers // This will remote the coolify.yaml file from the server as it is not needed on cloud servers
if (isCloud() && $this->server->id !== 0) { if (isCloud() && $this->server->id !== 0) {
$file = $this->server->proxyPath() . '/dynamic/coolify.yaml'; $file = $this->server->proxyPath().'/dynamic/coolify.yaml';
return instant_remote_process([ return instant_remote_process([
"rm -f $file", "rm -f $file",

View File

@ -41,6 +41,7 @@ class ServerCpu extends Component
return handleError($e, $this); return handleError($e, $this);
} }
} }
public function setInterval() public function setInterval()
{ {
$this->loadData(); $this->loadData();

View File

@ -14,12 +14,14 @@ class ServerMemory extends Component
public $data; public $data;
public $categories; public $categories;
public $interval = 5; public $interval = 5;
public function render() public function render()
{ {
return view('livewire.charts.server-memory'); return view('livewire.charts.server-memory');
} }
public function mount() public function mount()
{ {
$this->loadData(); $this->loadData();
@ -39,7 +41,9 @@ class ServerMemory extends Component
return handleError($e, $this); return handleError($e, $this);
} }
} }
public function setInterval() {
public function setInterval()
{
$this->loadData(); $this->loadData();
} }
} }

View File

@ -104,7 +104,9 @@ class Form extends Component
return handleError($e, $this); return handleError($e, $this);
} }
} }
public function restartSentinel() {
public function restartSentinel()
{
try { try {
$version = get_latest_sentinel_version(); $version = get_latest_sentinel_version();
StartSentinel::run($this->server, $version, true); StartSentinel::run($this->server, $version, true);

View File

@ -131,7 +131,7 @@ class Server extends BaseModel
public function setupDefault404Redirect() public function setupDefault404Redirect()
{ {
$dynamic_conf_path = $this->proxyPath() . '/dynamic'; $dynamic_conf_path = $this->proxyPath().'/dynamic';
$proxy_type = $this->proxyType(); $proxy_type = $this->proxyType();
$redirect_url = $this->proxy->redirect_url; $redirect_url = $this->proxy->redirect_url;
if ($proxy_type === 'TRAEFIK_V2') { if ($proxy_type === 'TRAEFIK_V2') {
@ -145,8 +145,8 @@ class Server extends BaseModel
respond 404 respond 404
}'; }';
$conf = $conf =
"# This file is automatically generated by Coolify.\n" . "# This file is automatically generated by Coolify.\n".
"# Do not edit it manually (only if you know what are you doing).\n\n" . "# Do not edit it manually (only if you know what are you doing).\n\n".
$conf; $conf;
$base64 = base64_encode($conf); $base64 = base64_encode($conf);
instant_remote_process([ instant_remote_process([
@ -205,8 +205,8 @@ respond 404
]; ];
$conf = Yaml::dump($dynamic_conf, 12, 2); $conf = Yaml::dump($dynamic_conf, 12, 2);
$conf = $conf =
"# This file is automatically generated by Coolify.\n" . "# This file is automatically generated by Coolify.\n".
"# Do not edit it manually (only if you know what are you doing).\n\n" . "# Do not edit it manually (only if you know what are you doing).\n\n".
$conf; $conf;
$base64 = base64_encode($conf); $base64 = base64_encode($conf);
@ -215,8 +215,8 @@ respond 404
redir $redirect_url redir $redirect_url
}"; }";
$conf = $conf =
"# This file is automatically generated by Coolify.\n" . "# This file is automatically generated by Coolify.\n".
"# Do not edit it manually (only if you know what are you doing).\n\n" . "# Do not edit it manually (only if you know what are you doing).\n\n".
$conf; $conf;
$base64 = base64_encode($conf); $base64 = base64_encode($conf);
} }
@ -237,7 +237,7 @@ respond 404
public function setupDynamicProxyConfiguration() public function setupDynamicProxyConfiguration()
{ {
$settings = InstanceSettings::get(); $settings = InstanceSettings::get();
$dynamic_config_path = $this->proxyPath() . '/dynamic'; $dynamic_config_path = $this->proxyPath().'/dynamic';
if ($this->proxyType() === 'TRAEFIK_V2') { if ($this->proxyType() === 'TRAEFIK_V2') {
$file = "$dynamic_config_path/coolify.yaml"; $file = "$dynamic_config_path/coolify.yaml";
if (empty($settings->fqdn) || (isCloud() && $this->id !== 0)) { if (empty($settings->fqdn) || (isCloud() && $this->id !== 0)) {
@ -330,8 +330,8 @@ respond 404
} }
$yaml = Yaml::dump($traefik_dynamic_conf, 12, 2); $yaml = Yaml::dump($traefik_dynamic_conf, 12, 2);
$yaml = $yaml =
"# This file is automatically generated by Coolify.\n" . "# This file is automatically generated by Coolify.\n".
"# Do not edit it manually (only if you know what are you doing).\n\n" . "# Do not edit it manually (only if you know what are you doing).\n\n".
$yaml; $yaml;
$base64 = base64_encode($yaml); $base64 = base64_encode($yaml);
@ -389,9 +389,9 @@ $schema://$host {
if ($proxyType === ProxyTypes::TRAEFIK_V2->value) { if ($proxyType === ProxyTypes::TRAEFIK_V2->value) {
$proxy_path = $proxy_path; $proxy_path = $proxy_path;
} elseif ($proxyType === ProxyTypes::CADDY->value) { } elseif ($proxyType === ProxyTypes::CADDY->value) {
$proxy_path = $proxy_path . '/caddy'; $proxy_path = $proxy_path.'/caddy';
} elseif ($proxyType === ProxyTypes::NGINX->value) { } elseif ($proxyType === ProxyTypes::NGINX->value) {
$proxy_path = $proxy_path . '/nginx'; $proxy_path = $proxy_path.'/nginx';
} }
return $proxy_path; return $proxy_path;
@ -466,6 +466,7 @@ $schema://$host {
{ {
return $this->settings->is_metrics_enabled; return $this->settings->is_metrics_enabled;
} }
public function checkSentinel() public function checkSentinel()
{ {
ray("Checking sentinel on server: {$this->name}"); ray("Checking sentinel on server: {$this->name}");
@ -507,6 +508,7 @@ $schema://$host {
return $parsedCollection; return $parsedCollection;
} }
} }
public function getMemoryMetrics(int $mins = 5) public function getMemoryMetrics(int $mins = 5)
{ {
if ($this->isMetricsEnabled()) { if ($this->isMetricsEnabled()) {
@ -646,7 +648,7 @@ $schema://$host {
$containers = instant_remote_process(["docker service inspect $(docker service ls -q) --format '{{json .}}'"], $this, false); $containers = instant_remote_process(["docker service inspect $(docker service ls -q) --format '{{json .}}'"], $this, false);
} else { } else {
$containers = instant_remote_process(['docker container ls -q'], $this, false); $containers = instant_remote_process(['docker container ls -q'], $this, false);
if (!$containers) { if (! $containers) {
return collect([]); return collect([]);
} }
$containers = instant_remote_process(["docker container inspect $(docker container ls -q) --format '{{json .}}'"], $this, false); $containers = instant_remote_process(["docker container inspect $(docker container ls -q) --format '{{json .}}'"], $this, false);
@ -666,7 +668,7 @@ $schema://$host {
$containers = format_docker_command_output_to_json($containers); $containers = format_docker_command_output_to_json($containers);
$containers = $containers->map(function ($container) { $containers = $containers->map(function ($container) {
$labels = data_get($container, 'Labels'); $labels = data_get($container, 'Labels');
if (!str($labels)->contains('coolify.managed')) { if (! str($labels)->contains('coolify.managed')) {
return $container; return $container;
} }
@ -738,7 +740,7 @@ $schema://$host {
return $this->previews()->filter(function ($preview) { return $this->previews()->filter(function ($preview) {
$applicationId = data_get($preview, 'application_id'); $applicationId = data_get($preview, 'application_id');
$application = Application::find($applicationId); $application = Application::find($applicationId);
if (!$application) { if (! $application) {
return false; return false;
} }
@ -822,9 +824,9 @@ $schema://$host {
public function isFunctional() public function isFunctional()
{ {
$isFunctional = $this->settings->is_reachable && $this->settings->is_usable && !$this->settings->force_disabled; $isFunctional = $this->settings->is_reachable && $this->settings->is_usable && ! $this->settings->force_disabled;
['private_key_filename' => $private_key_filename, 'mux_filename' => $mux_filename] = server_ssh_configuration($this); ['private_key_filename' => $private_key_filename, 'mux_filename' => $mux_filename] = server_ssh_configuration($this);
if (!$isFunctional) { if (! $isFunctional) {
Storage::disk('ssh-keys')->delete($private_key_filename); Storage::disk('ssh-keys')->delete($private_key_filename);
Storage::disk('ssh-mux')->delete($mux_filename); Storage::disk('ssh-mux')->delete($mux_filename);
} }
@ -883,7 +885,7 @@ $schema://$host {
config()->set('coolify.mux_enabled', false); config()->set('coolify.mux_enabled', false);
$server = Server::find($this->id); $server = Server::find($this->id);
if (!$server) { if (! $server) {
return ['uptime' => false, 'error' => 'Server not found.']; return ['uptime' => false, 'error' => 'Server not found.'];
} }
if ($server->skipServer()) { if ($server->skipServer()) {

View File

@ -163,6 +163,7 @@ function get_latest_sentinel_version(): string
try { try {
$response = Http::get('https://cdn.coollabs.io/coolify/versions.json'); $response = Http::get('https://cdn.coollabs.io/coolify/versions.json');
$versions = $response->json(); $versions = $response->json();
return data_get($versions, 'coolify.sentinel.version'); return data_get($versions, 'coolify.sentinel.version');
} catch (\Throwable $e) { } catch (\Throwable $e) {
//throw $e; //throw $e;
@ -2285,7 +2286,9 @@ function isAnyDeploymentInprogress()
exit(0); exit(0);
} }
function generateSentinelToken() { function generateSentinelToken()
{
$token = Str::random(64); $token = Str::random(64);
return $token; return $token;
} }

View File

@ -1,6 +1,5 @@
<?php <?php
use App\Models\Server;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;