return;
// Checking the number of workers
- if (poller_too_much_workers(1)) {
+ if (poller_too_much_workers()) {
poller_kill_stale_workers();
return;
}
sleep(4);
// Checking number of workers
- if (poller_too_much_workers(2))
+ if (poller_too_much_workers())
return;
$cooldown = Config::get("system", "worker_cooldown", 0);
return;
// Count active workers and compare them with a maximum value that depends on the load
- if (poller_too_much_workers(3))
+ if (poller_too_much_workers())
return;
q("UPDATE `workerqueue` SET `executed` = '%s', `pid` = %d WHERE `id` = %d AND `executed` = '0000-00-00 00:00:00'",
}
}
-function poller_too_much_workers($stage) {
+function poller_too_much_workers() {
$queues = get_config("system", "worker_queues");
$slope = $maxworkers / pow($maxsysload, $exponent);
$queues = ceil($slope * pow(max(0, $maxsysload - $load), $exponent));
- logger("Current load stage ".$stage.": ".$load." - maximum: ".$maxsysload." - current queues: ".$active." - maximum: ".$queues, LOGGER_DEBUG);
+ $s = q("SELECT COUNT(*) AS `total` FROM `workerqueue` WHERE `executed` = '0000-00-00 00:00:00'");
+
+ logger("Current load: ".$load." - maximum: ".$maxsysload." - current queues: ".$active."/".$s[0]["total"]." - maximum: ".$queues, LOGGER_DEBUG);
}