From a8401182afbcdd4dd7ebd5488956ac0d6ed5923c Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 17 Dec 2024 23:18:40 +0100 Subject: [PATCH] add debug logs to debug the logs - lol --- app/Models/Server.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/app/Models/Server.php b/app/Models/Server.php index 6abc7cb43..767327b8e 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -1026,11 +1026,21 @@ $schema://$host { $unreachableNotificationSent = (bool) $this->unreachable_notification_sent; $isReachable = (bool) $this->settings->is_reachable; + \Log::debug('Server reachability check', [ + 'server_id' => $this->id, + 'is_reachable' => $isReachable, + 'notification_sent' => $unreachableNotificationSent, + 'unreachable_count' => $this->unreachable_count, + ]); + if ($isReachable === true) { $this->unreachable_count = 0; $this->save(); if ($unreachableNotificationSent === true) { + \Log::debug('Server is now reachable, sending notification', [ + 'server_id' => $this->id, + ]); $this->sendReachableNotification(); } @@ -1038,9 +1048,17 @@ $schema://$host { } $this->increment('unreachable_count'); + \Log::debug('Incremented unreachable count', [ + 'server_id' => $this->id, + 'new_count' => $this->unreachable_count, + ]); + if ($this->unreachable_count === 1) { $this->settings->is_reachable = true; $this->settings->save(); + \Log::debug('First unreachable attempt, marking as reachable', [ + 'server_id' => $this->id, + ]); return; } @@ -1049,6 +1067,11 @@ $schema://$host { $failedChecks = 0; for ($i = 0; $i < 3; $i++) { $status = $this->serverStatus(); + \Log::debug('Additional reachability check', [ + 'server_id' => $this->id, + 'attempt' => $i + 1, + 'status' => $status, + ]); sleep(5); if (! $status) { $failedChecks++; @@ -1056,6 +1079,9 @@ $schema://$host { } if ($failedChecks === 3 && ! $unreachableNotificationSent) { + \Log::debug('Server confirmed unreachable after 3 attempts, sending notification', [ + 'server_id' => $this->id, + ]); $this->sendUnreachableNotification(); } }