X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=inline;f=include%2Fpoller.php;h=5560b3340e6209fc4ab82c97ecd3619bc9840afc;hb=29306017198ade568f50718392b3df5a92bd04cc;hp=6eb4aef0637072c0577797829cd416c0c02d3001;hpb=1624150db4d0f511d7d119eb645e997bd3f76129;p=friendica.git diff --git a/include/poller.php b/include/poller.php index 6eb4aef063..5560b3340e 100644 --- a/include/poller.php +++ b/include/poller.php @@ -35,6 +35,10 @@ function poller_run($argv, $argc){ return; } + $a->set_baseurl(Config::get('system', 'url')); + + load_hooks(); + $a->start_process(); if (poller_max_connections_reached()) { @@ -360,11 +364,11 @@ function poller_kill_stale_workers() { return; } - foreach($r AS $pid) - if (!posix_kill($pid["pid"], 0)) + foreach ($r AS $pid) { + if (!posix_kill($pid["pid"], 0)) { q("UPDATE `workerqueue` SET `executed` = '%s', `pid` = 0 WHERE `pid` = %d", dbesc(NULL_DATE), intval($pid["pid"])); - else { + } else { // Kill long running processes // Check if the priority is in a valid range @@ -393,9 +397,11 @@ function poller_kill_stale_workers() { dbesc(datetime_convert()), intval(PRIORITY_NEGLIGIBLE), intval($pid["pid"])); - } else + } else { logger("Worker process ".$pid["pid"]." (".implode(" ", $argv).") now runs for ".round($duration)." of ".$max_duration." allowed minutes. That's okay.", LOGGER_DEBUG); + } } + } } /** @@ -465,7 +471,7 @@ function poller_too_much_workers() { // Are there fewer workers running as possible? Then fork a new one. if (!Config::get("system", "worker_dont_fork") AND ($queues > ($active + 1)) AND ($entries > 1)) { logger("Active workers: ".$active."/".$queues." Fork a new worker.", LOGGER_DEBUG); - $args = array("php", "include/poller.php", "no_cron"); + $args = array("include/poller.php", "no_cron"); $a = get_app(); $a->proc_run($args); } @@ -554,9 +560,9 @@ function poller_worker_process() { ORDER BY `priority`, `created` LIMIT 1", dbesc(NULL_DATE), intval($highest_priority)); - if (dbm::is_result($r)) + if (dbm::is_result($r)) { return $r; - + } // Give slower processes some processing time $r = q("SELECT * FROM `workerqueue` WHERE `executed` <= '%s' AND `priority` > %d @@ -566,9 +572,9 @@ function poller_worker_process() { } // If there is no result (or we shouldn't pass lower processes) we check without priority limit - if (($highest_priority == 0) OR !dbm::is_result($r)) + if (($highest_priority == 0) OR !dbm::is_result($r)) { $r = q("SELECT * FROM `workerqueue` WHERE `executed` <= '%s' ORDER BY `priority`, `created` LIMIT 1", dbesc(NULL_DATE)); - + } return $r; } @@ -576,7 +582,7 @@ function poller_worker_process() { * @brief Call the front end worker */ function call_worker() { - if (!Config::get("system", "frontend_worker") OR !Config::get("system", "worker")) { + if (!Config::get("system", "frontend_worker")) { return; } @@ -588,7 +594,7 @@ function call_worker() { * @brief Call the front end worker if there aren't any active */ function call_worker_if_idle() { - if (!Config::get("system", "frontend_worker") OR !Config::get("system", "worker")) { + if (!Config::get("system", "frontend_worker")) { return; } @@ -615,7 +621,7 @@ function call_worker_if_idle() { logger('Call poller', LOGGER_DEBUG); - $args = array("php", "include/poller.php", "no_cron"); + $args = array("include/poller.php", "no_cron"); $a = get_app(); $a->proc_run($args); return;