From 6826b6e1f81d473042bf222482e3ff018a7a9450 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 16 May 2024 10:08:00 +0200 Subject: [PATCH] Refactor container status and log drain checks scheduling --- app/Console/Kernel.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index dfbcf7870..30276f729 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -78,22 +78,28 @@ private function check_resources($schedule) } foreach ($containerServers as $server) { $schedule->job(new ContainerStatusJob($server))->everyTwoMinutes()->onOneServer()->before(function () { - $wait = rand(5, 20); - ray('waiting for ' . $wait . ' seconds'); - Sleep::for($wait)->seconds(); - ray('waited for ' . $wait . ' seconds'); + if (isCloud()) { + $wait = rand(5, 20); + ray('waiting for ' . $wait . ' seconds'); + Sleep::for($wait)->seconds(); + ray('waited for ' . $wait . ' seconds'); + } }); if ($server->isLogDrainEnabled()) { $schedule->job(new CheckLogDrainContainerJob($server))->everyTwoMinutes()->onOneServer()->before(function () { - $wait = rand(5, 20); - Sleep::for($wait)->seconds(); + if (isCloud()) { + $wait = rand(5, 20); + Sleep::for($wait)->seconds(); + } }); } } foreach ($servers as $server) { $schedule->job(new ServerStatusJob($server))->everyTwoMinutes()->onOneServer()->before(function () { - $wait = rand(5, 20); - Sleep::for($wait)->seconds(); + if (isCloud()) { + $wait = rand(5, 20); + Sleep::for($wait)->seconds(); + } }); } }