return;
}
+ $a->set_baseurl(Config::get('system', 'url'));
+
+ load_hooks();
+
$a->start_process();
if (poller_max_connections_reached()) {
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
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);
+ }
}
+ }
}
/**
// 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);
}
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
}
// 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;
}
* @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;
}
* @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;
}
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;