Refactor scheduling of container status and log drain checks

This commit is contained in:
Andras Bacsai 2024-05-16 11:23:31 +02:00
parent b106a82308
commit 2b74ca2746

View File

@ -18,7 +18,6 @@
use App\Models\Team; use App\Models\Team;
use Illuminate\Console\Scheduling\Schedule; use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel; use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use Illuminate\Support\Sleep;
class Kernel extends ConsoleKernel class Kernel extends ConsoleKernel
{ {
@ -77,28 +76,13 @@ private function check_resources($schedule)
$containerServers = $servers->where('settings.is_swarm_worker', false)->where('settings.is_build_server', false); $containerServers = $servers->where('settings.is_swarm_worker', false)->where('settings.is_build_server', false);
} }
foreach ($containerServers as $server) { foreach ($containerServers as $server) {
$schedule->job(new ContainerStatusJob($server))->everyTwoMinutes()->onOneServer()->before(function () { $schedule->job(new ContainerStatusJob($server))->everyMinute()->onOneServer();
if (isCloud()) {
$wait = rand(5, 20);
Sleep::for($wait)->seconds();
}
});
if ($server->isLogDrainEnabled()) { if ($server->isLogDrainEnabled()) {
$schedule->job(new CheckLogDrainContainerJob($server))->everyTwoMinutes()->onOneServer()->before(function () { $schedule->job(new CheckLogDrainContainerJob($server))->everyMinute()->onOneServer();
if (isCloud()) {
$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))->everyMinute()->onOneServer();
if (isCloud()) {
$wait = rand(5, 20);
Sleep::for($wait)->seconds();
}
});
} }
} }
private function instance_auto_update($schedule) private function instance_auto_update($schedule)