Split cron jobs in cronjobs, introduce fastlane for high priority tasks

This commit is contained in:
Michael Vogel 2016-08-03 10:03:05 +02:00
parent ba3bde5fb5
commit d673f44c5b
3 changed files with 149 additions and 32 deletions

View file

@ -270,6 +270,24 @@ function poller_too_much_workers() {
$slope = $maxworkers / pow($maxsysload, $exponent);
$queues = ceil($slope * pow(max(0, $maxsysload - $load), $exponent));
if (Config::get("system", "worker_fastlane", false) AND ($queues > 0) AND ($active >= $queues)) {
$s = q("SELECT COUNT(*) AS `total` FROM `workerqueue` WHERE `priority` = %d AND `executed` = '0000-00-00 00:00:00'",
intval(PRIORITY_HIGH));
$high_waiting = $s[0]["total"];
$s = q("SELECT COUNT(*) AS `total` FROM `workerqueue` WHERE `priority` = %d AND `executed` != '0000-00-00 00:00:00'",
intval(PRIORITY_HIGH));
$high_running = $s[0]["total"];
logger("High waiting: ".$high_waiting." - high running: ".$high_running);
/// @todo define maximum number of fastlanes
if (($high_waiting > 0) AND ($high_running == 0)) {
logger("There are ".$high_waiting." high priority jobs waiting but none is executed. Open a fastlane.", LOGGER_DEBUG);
$queue = $active + 1;
}
}
$s = q("SELECT COUNT(*) AS `total` FROM `workerqueue` WHERE `executed` = '0000-00-00 00:00:00'");
$entries = $s[0]["total"];