Adding a cooldown phase for the daemon

This commit is contained in:
Michael 2020-08-19 18:21:40 +00:00
commit 98dd15ec9a
2 changed files with 45 additions and 23 deletions

View file

@ -185,7 +185,12 @@ while (true) {
$do_cron = true;
}
Worker::spawnWorker($do_cron);
if ($do_cron || (!DI::process()->isMaxLoadReached() && Worker::entriesExists() && Worker::isReady())) {
Worker::spawnWorker($do_cron);
} else {
Logger::info('Cool down', ['pid' => $pid]);
sleep(10);
}
if ($do_cron) {
// We force a reconnect of the database connection.