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 Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use Illuminate\Support\Sleep;
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);
}
foreach ($containerServers as $server) {
$schedule->job(new ContainerStatusJob($server))->everyTwoMinutes()->onOneServer()->before(function () {
if (isCloud()) {
$wait = rand(5, 20);
Sleep::for($wait)->seconds();
}
});
$schedule->job(new ContainerStatusJob($server))->everyMinute()->onOneServer();
if ($server->isLogDrainEnabled()) {
$schedule->job(new CheckLogDrainContainerJob($server))->everyTwoMinutes()->onOneServer()->before(function () {
if (isCloud()) {
$wait = rand(5, 20);
Sleep::for($wait)->seconds();
}
});
$schedule->job(new CheckLogDrainContainerJob($server))->everyMinute()->onOneServer();
}
}
foreach ($servers as $server) {
$schedule->job(new ServerStatusJob($server))->everyTwoMinutes()->onOneServer()->before(function () {
if (isCloud()) {
$wait = rand(5, 20);
Sleep::for($wait)->seconds();
}
});
$schedule->job(new ServerStatusJob($server))->everyMinute()->onOneServer();
}
}
private function instance_auto_update($schedule)