refactor(Server): remove debug logging from isReachableChanged method to clean up code and improve performance

This commit is contained in:
Andras Bacsai
2025-04-14 10:30:53 +02:00
parent eda1e1899f
commit 8b3c4d7ad9

View File

@@ -20,7 +20,6 @@ use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Carbon;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Stringable;
use OpenApi\Attributes as OA;
@@ -1026,22 +1025,11 @@ $schema://$host {
$this->refresh();
$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();
}
@@ -1049,17 +1037,10 @@ $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;
}
@@ -1068,11 +1049,6 @@ $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++;
@@ -1080,9 +1056,6 @@ $schema://$host {
}
if ($failedChecks === 3 && ! $unreachableNotificationSent) {
Log::debug('Server confirmed unreachable after 3 attempts, sending notification', [
'server_id' => $this->id,
]);
$this->sendUnreachableNotification();
}
}