]> git.mxchange.org Git - friendica.git/blobdiff - include/poller.php
Merge pull request #2853 from annando/1610-bugfix-config
[friendica.git] / include / poller.php
index ce2a6be0fa62a1c9c1cccd2b8fd297f77bb9f39d..61ec89e59766c0244b1791e48c5a560dea3ecc6f 100644 (file)
@@ -29,6 +29,10 @@ function poller_run(&$argv, &$argc){
                unset($db_host, $db_user, $db_pass, $db_data);
        };
 
+       // Quit when in maintenance
+       if (get_config('system', 'maintenance', true))
+               return;
+
        $a->start_process();
 
        $mypid = getmypid();
@@ -71,6 +75,10 @@ function poller_run(&$argv, &$argc){
 
        while ($r = q("SELECT * FROM `workerqueue` WHERE `executed` = '0000-00-00 00:00:00' ORDER BY `priority`, `created` LIMIT 1")) {
 
+               // Quit when in maintenance
+               if (get_config('system', 'maintenance', true))
+                       return;
+
                // Constantly check the number of parallel database processes
                if ($a->max_processes_reached())
                        return;
@@ -120,8 +128,16 @@ function poller_run(&$argv, &$argc){
 
                if (function_exists($funcname)) {
                        logger("Process ".$mypid." - Prio ".$r[0]["priority"]." - ID ".$r[0]["id"].": ".$funcname." ".$r[0]["parameter"]);
+
+                       // For better logging create a new process id for every worker call
+                       // But preserve the old one for the worker
+                       $old_process_id = $a->process_id;
+                       $a->process_id = uniqid("wrk", true);
+
                        $funcname($argv, $argc);
 
+                       $a->process_id = $old_process_id;
+
                        if ($cooldown > 0) {
                                logger("Process ".$mypid." - Prio ".$r[0]["priority"]." - ID ".$r[0]["id"].": ".$funcname." - in cooldown for ".$cooldown." seconds");
                                sleep($cooldown);