Refactor container status and log drain checks scheduling

This commit is contained in:
Andras Bacsai 2024-05-16 10:08:00 +02:00
parent 27c4fa2fcf
commit 6826b6e1f8

View File

@ -78,22 +78,28 @@ private function check_resources($schedule)
} }
foreach ($containerServers as $server) { foreach ($containerServers as $server) {
$schedule->job(new ContainerStatusJob($server))->everyTwoMinutes()->onOneServer()->before(function () { $schedule->job(new ContainerStatusJob($server))->everyTwoMinutes()->onOneServer()->before(function () {
$wait = rand(5, 20); if (isCloud()) {
ray('waiting for ' . $wait . ' seconds'); $wait = rand(5, 20);
Sleep::for($wait)->seconds(); ray('waiting for ' . $wait . ' seconds');
ray('waited for ' . $wait . ' seconds'); Sleep::for($wait)->seconds();
ray('waited for ' . $wait . ' seconds');
}
}); });
if ($server->isLogDrainEnabled()) { if ($server->isLogDrainEnabled()) {
$schedule->job(new CheckLogDrainContainerJob($server))->everyTwoMinutes()->onOneServer()->before(function () { $schedule->job(new CheckLogDrainContainerJob($server))->everyTwoMinutes()->onOneServer()->before(function () {
$wait = rand(5, 20); if (isCloud()) {
Sleep::for($wait)->seconds(); $wait = rand(5, 20);
Sleep::for($wait)->seconds();
}
}); });
} }
} }
foreach ($servers as $server) { foreach ($servers as $server) {
$schedule->job(new ServerStatusJob($server))->everyTwoMinutes()->onOneServer()->before(function () { $schedule->job(new ServerStatusJob($server))->everyTwoMinutes()->onOneServer()->before(function () {
$wait = rand(5, 20); if (isCloud()) {
Sleep::for($wait)->seconds(); $wait = rand(5, 20);
Sleep::for($wait)->seconds();
}
}); });
} }
} }