Merge pull request #5173 from annando/more-daemon

Ensure that cron workers are called even at busy times
This commit is contained in:
Tobias Diekershoff 2018-06-06 08:49:26 +02:00 committed by GitHub
commit b53e74d989
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -127,11 +127,21 @@ file_put_contents($pidfile, $pid);
$wait_interval = intval(Config::get('system', 'cron_interval', 5)) * 60; $wait_interval = intval(Config::get('system', 'cron_interval', 5)) * 60;
$do_cron = true; $do_cron = true;
$last_cron = 0;
// Now running as a daemon. // Now running as a daemon.
while (true) { while (true) {
if (!$do_cron && ($last_cron + $wait_interval) < time()) {
logger('Forcing cron worker call.', LOGGER_DEBUG);
$do_cron = true;
}
Worker::spawnWorker($do_cron); Worker::spawnWorker($do_cron);
if ($do_cron) {
$last_cron = time();
}
logger("Sleeping", LOGGER_DEBUG); logger("Sleeping", LOGGER_DEBUG);
$i = 0; $i = 0;
do { do {