From 11a957c6c9120fcb9e48fe9c00ffef9a22b0fbd2 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 15 Dec 2023 10:01:14 +0100 Subject: [PATCH] fix: server checking status --- app/Models/Server.php | 9 +++++---- app/Notifications/Server/Unreachable.php | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/Models/Server.php b/app/Models/Server.php index 1ac8bbe27..a5577f6c1 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -153,14 +153,15 @@ public function skipServer() public function isServerReady() { $serverUptimeCheckNumber = $this->unreachable_count; - $serverUptimeCheckNumberMax = 12; + $serverUptimeCheckNumberMax = 8; $currentTime = now()->timestamp; - $runtime = 65; + $runtime = 50; $isReady = false; - // Run for 65 seconds max and check every 5 seconds for 12 times + // Run for 50 seconds max and check every 5 seconds for 8 times while ($currentTime + $runtime > now()->timestamp) { + ray('serverUptimeCheckNumber: ' . $serverUptimeCheckNumber); if ($serverUptimeCheckNumber >= $serverUptimeCheckNumberMax) { if ($this->unreachable_notification_sent === false) { ray('Server unreachable, sending notification...'); @@ -200,7 +201,7 @@ public function isServerReady() 'unreachable_count' => $serverUptimeCheckNumber, ]); Sleep::for(5)->seconds(); - return; + continue; } $isReady = true; break; diff --git a/app/Notifications/Server/Unreachable.php b/app/Notifications/Server/Unreachable.php index 07f801fe8..fe9b46a11 100644 --- a/app/Notifications/Server/Unreachable.php +++ b/app/Notifications/Server/Unreachable.php @@ -43,7 +43,7 @@ public function via(object $notifiable): array public function toMail(): MailMessage { $mail = new MailMessage(); - $mail->subject("Coolify: Server ({$this->server->name}) is unreachable after trying to connect to it 3 times"); + $mail->subject("Coolify: Your server ({$this->server->name}) is unreachable."); $mail->view('emails.server-lost-connection', [ 'name' => $this->server->name, ]); @@ -52,13 +52,13 @@ public function toMail(): MailMessage public function toDiscord(): string { - $message = "Coolify: Server '{$this->server->name}' is unreachable after trying to connect to it 3 times. All automations & integrations are turned off! Please check your server! IMPORTANT: We automatically try to revive your server. If your server is back online, we will automatically turn on all automations & integrations."; + $message = "Coolify: Your server '{$this->server->name}' is unreachable. All automations & integrations are turned off! Please check your server! IMPORTANT: We automatically try to revive your server. If your server is back online, we will automatically turn on all automations & integrations."; return $message; } public function toTelegram(): array { return [ - "message" => "Coolify: Server '{$this->server->name}' is unreachable after trying to connect to it 3 times. All automations & integrations are turned off! Please check your server! IMPORTANT: We automatically try to revive your server. If your server is back online, we will automatically turn on all automations & integrations." + "message" => "Coolify: Your server '{$this->server->name}' is unreachable. All automations & integrations are turned off! Please check your server! IMPORTANT: We automatically try to revive your server. If your server is back online, we will automatically turn on all automations & integrations." ]; } }