From 83983bbb323e421197929892a6426cbb01e12b8e Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 18 Jun 2024 13:01:23 +0200 Subject: [PATCH] fix: remove sentinel variable fix: metrics are disabled by default --- app/Console/Kernel.php | 2 +- app/Jobs/PullSentinelImageJob.php | 1 - app/Jobs/ServerStatusJob.php | 8 ++--- config/coolify.php | 1 - ...5947_disable_server_metrics_by_default.php | 31 +++++++++++++++++++ 5 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 database/migrations/2024_06_18_105947_disable_server_metrics_by_default.php diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index e2698d90e..df4d560f5 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -61,7 +61,7 @@ private function pull_images($schedule) { $servers = $this->all_servers->where('settings.is_usable', true)->where('settings.is_reachable', true)->where('ip', '!=', '1.2.3.4'); foreach ($servers as $server) { - if (config('coolify.is_sentinel_enabled')) { + if ($server->is_metrics_enabled) { $schedule->job(new PullSentinelImageJob($server))->everyFiveMinutes()->onOneServer(); } $schedule->job(new PullHelperImageJob($server))->everyFiveMinutes()->onOneServer(); diff --git a/app/Jobs/PullSentinelImageJob.php b/app/Jobs/PullSentinelImageJob.php index 08b324deb..232d00223 100644 --- a/app/Jobs/PullSentinelImageJob.php +++ b/app/Jobs/PullSentinelImageJob.php @@ -50,7 +50,6 @@ public function handle(): void } if (version_compare($local_version, $version, '<')) { StartSentinel::run($this->server, $version, true); - return; } ray('Sentinel image is up to date'); diff --git a/app/Jobs/ServerStatusJob.php b/app/Jobs/ServerStatusJob.php index aaf8f5784..6dfe2792b 100644 --- a/app/Jobs/ServerStatusJob.php +++ b/app/Jobs/ServerStatusJob.php @@ -41,19 +41,19 @@ public function uniqueId(): int public function handle() { - if (! $this->server->isServerReady($this->tries)) { + if (!$this->server->isServerReady($this->tries)) { throw new \RuntimeException('Server is not ready.'); } try { if ($this->server->isFunctional()) { $this->cleanup(notify: false); $this->remove_unnecessary_coolify_yaml(); - if (config('coolify.is_sentinel_enabled')) { + if ($this->server->is_metrics_enabled) { $this->server->checkSentinel(); } } } catch (\Throwable $e) { - send_internal_notification('ServerStatusJob failed with: '.$e->getMessage()); + send_internal_notification('ServerStatusJob failed with: ' . $e->getMessage()); ray($e->getMessage()); return handleError($e); @@ -103,7 +103,7 @@ private function remove_unnecessary_coolify_yaml() { // This will remote the coolify.yaml file from the server as it is not needed on cloud servers if (isCloud() && $this->server->id !== 0) { - $file = $this->server->proxyPath().'/dynamic/coolify.yaml'; + $file = $this->server->proxyPath() . '/dynamic/coolify.yaml'; return instant_remote_process([ "rm -f $file", diff --git a/config/coolify.php b/config/coolify.php index c7cfe6101..a6d6d8581 100644 --- a/config/coolify.php +++ b/config/coolify.php @@ -14,5 +14,4 @@ 'helper_image' => env('HELPER_IMAGE', 'ghcr.io/coollabsio/coolify-helper:latest'), 'is_horizon_enabled' => env('HORIZON_ENABLED', true), 'is_scheduler_enabled' => env('SCHEDULER_ENABLED', true), - 'is_sentinel_enabled' => env('SENTINEL_ENABLED', false), ]; diff --git a/database/migrations/2024_06_18_105947_disable_server_metrics_by_default.php b/database/migrations/2024_06_18_105947_disable_server_metrics_by_default.php new file mode 100644 index 000000000..5338f457d --- /dev/null +++ b/database/migrations/2024_06_18_105947_disable_server_metrics_by_default.php @@ -0,0 +1,31 @@ +boolean('is_metrics_enabled')->default(false)->change(); + }); + Server::where('is_metrics_enabled', true)->update(['is_metrics_enabled' => false]); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('servers', function (Blueprint $table) { + $table->boolean('is_metrics_enabled')->default(true)->change(); + }); + Server::where('is_metrics_enabled', false)->update(['is_metrics_enabled' => true]); + } +};