From 8c73068cc758c2a563dea5ca57587a117b1ca63f Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 17 Nov 2023 13:11:46 +0100 Subject: [PATCH] Refactor server filtering logic in Kernel.php --- app/Console/Kernel.php | 6 +++--- app/Models/Server.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index e0d9f2752..7f8c86b94 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -43,7 +43,7 @@ protected function schedule(Schedule $schedule): void } private function pull_helper_image($schedule) { - $servers = Server::all()->where('settings.is_usable', true)->where('settings.is_reachable', true); + $servers = Server::all()->where('settings.is_usable', true)->where('settings.is_reachable', true)->where('ip', '!=', '1.2.3.4'); foreach ($servers as $server) { $schedule->job(new PullHelperImageJob($server))->everyTenMinutes()->onOneServer(); } @@ -51,9 +51,9 @@ private function pull_helper_image($schedule) private function check_resources($schedule) { if (isCloud()) { - $servers = Server::all()->whereNotNull('team.subscription')->where('team.subscription.stripe_trial_already_ended', false); + $servers = Server::all()->whereNotNull('team.subscription')->where('team.subscription.stripe_trial_already_ended', false)->where('ip', '!=', '1.2.3.4'); } else { - $servers = Server::all(); + $servers = Server::all()->where('ip', '!=', '1.2.3.4'); } foreach ($servers as $server) { $schedule->job(new ServerStatusJob($server))->everyTenMinutes()->onOneServer(); diff --git a/app/Models/Server.php b/app/Models/Server.php index 1461f8cdc..15be118a8 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -168,7 +168,7 @@ public function checkServerRediness() $db->update(['status' => 'exited']); } } - throw new \Exception('Server is not reachable.'); + return false; } $result = $this->validateConnection(); ray('validateConnection: ' . $result);