4 * @brief Module for running the poller as frontend process
6 require_once("include/poller.php");
8 use \Friendica\Core\Config;
9 use \Friendica\Core\PConfig;
11 function worker_init($a){
13 if (!Config::get("system", "frontend_worker") OR !Config::get("system", "worker")) {
17 // We don't need the following lines if we can execute background jobs
18 if (function_exists("proc_open")) {
22 clear_worker_processes();
24 $workers = q("SELECT COUNT(*) AS `processes` FROM `process` WHERE `command` = 'worker.php'");
26 if ($workers[0]["processes"] > Config::get("system", "worker_queues", 4)) {
32 logger("Front end worker started: ".getmypid());
36 if ($r = poller_worker_process()) {
38 // On most configurations this parameter wouldn't have any effect.
39 // But since it doesn't destroy anything, we just try to get more execution time in any way.
42 poller_execute($r[0]);
49 logger("Front end worker ended: ".getmypid());