From fb447e84ee64243b00332329b72d85d726fd2119 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Fri, 22 Jul 2016 18:07:04 +0200 Subject: [PATCH] Some more information about the current queue status of the worker --- include/poller.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/include/poller.php b/include/poller.php index 9ea0aac1b3..bf25549b54 100644 --- a/include/poller.php +++ b/include/poller.php @@ -39,7 +39,7 @@ function poller_run(&$argv, &$argc){ return; // Checking the number of workers - if (poller_too_much_workers(1)) { + if (poller_too_much_workers()) { poller_kill_stale_workers(); return; } @@ -58,7 +58,7 @@ function poller_run(&$argv, &$argc){ 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); @@ -76,7 +76,7 @@ function poller_run(&$argv, &$argc){ 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'", @@ -244,7 +244,7 @@ function poller_kill_stale_workers() { } } -function poller_too_much_workers($stage) { +function poller_too_much_workers() { $queues = get_config("system", "worker_queues"); @@ -267,7 +267,9 @@ function poller_too_much_workers($stage) { $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); } -- 2.39.5