]> git.mxchange.org Git - friendica.git/commitdiff
The worker is now working
authorMichael Vogel <icarus@dabo.de>
Thu, 10 Sep 2015 21:10:31 +0000 (23:10 +0200)
committerMichael Vogel <icarus@dabo.de>
Thu, 10 Sep 2015 21:10:31 +0000 (23:10 +0200)
boot.php
include/onepoll.php
include/poller.php
include/socgraph.php
include/worker.php

index 7f3238013a779c3f720f04f4e71335b6cf930438..b3b926521919662dda81da660f503be4bb309d36 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -1433,21 +1433,24 @@ if(! function_exists('proc_run')) {
                        return;
 
                if(count($args) && $args[0] === 'php') {
-                       $argv = $args;
-                       array_shift($argv);
 
-                       $parameters = json_encode($argv);
-                       $found = q("SELECT `id` FROM `workerqueue` WHERE `parameter` = '%s'",
-                                       dbesc($parameters));
+                       if (get_config("system", "worker")) {
+                               $argv = $args;
+                               array_shift($argv);
 
-                       if (!$found)
-                               q("INSERT INTO `workerqueue` (`parameter`, `created`, `priority`)
-                                                       VALUES ('%s', '%s', %d)",
-                                       dbesc($parameters),
-                                       dbesc(datetime_convert()),
-                                       intval(0));
+                               $parameters = json_encode($argv);
+                               $found = q("SELECT `id` FROM `workerqueue` WHERE `parameter` = '%s'",
+                                               dbesc($parameters));
 
-                       // return;
+                               if (!$found)
+                                       q("INSERT INTO `workerqueue` (`parameter`, `created`, `priority`)
+                                                               VALUES ('%s', '%s', %d)",
+                                               dbesc($parameters),
+                                               dbesc(datetime_convert()),
+                                               intval(0));
+
+                               return;
+                       }
 
                        $args[0] = ((x($a->config,'php_path')) && (strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php');
                }
index 1fc861afa2a4f2fa0648110cf197fc2cd2967ded..e8fc97b21e9676c44cf03a34ac6c0ab130f0010a 100644 (file)
@@ -360,7 +360,7 @@ function onepoll_run(&$argv, &$argc){
                                );
                                logger("Mail: Connected to " . $mailconf[0]['user']);
                        } else
-                               logger("Mail: Connection error ".$mailconf[0]['user']." ".print_r(imap_errors()));
+                               logger("Mail: Connection error ".$mailconf[0]['user']." ".print_r(imap_errors(), true));
                }
                if($mbox) {
 
index 28dc0c0cde03748f926822923b6855d9b70aba4e..e47ab3782a1b9273f6d708434c5b4c45bf0fd93d 100644 (file)
@@ -75,22 +75,6 @@ function poller_run(&$argv, &$argc){
 
        logger('poller: start');
 
-       // run queue delivery process in the background
-
-       proc_run('php',"include/queue.php");
-
-       // run diaspora photo queue process in the background
-
-       proc_run('php',"include/dsprphotoq.php");
-
-       // run the process to discover global contacts in the background
-
-       proc_run('php',"include/discover_poco.php");
-
-       // run the process to update locally stored global contacts in the background
-
-       proc_run('php',"include/discover_poco.php", "checkcontact");
-
        // expire any expired accounts
 
        q("UPDATE user SET `account_expired` = 1 where `account_expired` = 0
@@ -119,7 +103,8 @@ function poller_run(&$argv, &$argc){
        check_conversations(false);
 
        // Follow your friends from your legacy OStatus account
-       ostatus_check_follow_friends();
+       // Doesn't work
+       // ostatus_check_follow_friends();
 
        // update nodeinfo data
        nodeinfo_cron();
index 97daae1d2eecd5c7be526e1eb7d5fed03bd4d2f3..6e2b6ea1588e8aba6f2f584ff9a709ffe74197de 100644 (file)
@@ -1338,8 +1338,10 @@ function poco_discover($complete = false) {
                                q("UPDATE `gserver` SET `last_poco_query` = '%s' WHERE `nurl` = '%s'", dbesc(datetime_convert()), dbesc($server["nurl"]));
                                if (!$complete AND (--$no_of_queries == 0))
                                        break;
-                       } else  // If the server hadn't replied correctly, then force a sanity check
-                               poco_check_server($server["url"], $server["network"], true);
+                       // If the server hadn't replied correctly, then force a sanity check
+                       } elseif (!poco_check_server($server["url"], $server["network"], true))
+                               q("UPDATE `gserver` SET `last_poco_query` = '%s' WHERE `nurl` = '%s'", dbesc(datetime_convert()), dbesc($server["nurl"]));
+
                }
 }
 
index e1eee388c9d3d65cf610f76c91ca8cb10ac14daf..c1d9202bafa5a383a4c59873f8bf93d749b99d09 100755 (executable)
@@ -26,6 +26,25 @@ if(is_null($db)) {
        unset($db_host, $db_user, $db_pass, $db_data);
 };
 
+// run queue delivery process in the background
+
+proc_run('php',"include/queue.php");
+
+// run diaspora photo queue process in the background
+
+proc_run('php',"include/dsprphotoq.php");
+
+// run the process to discover global contacts in the background
+
+proc_run('php',"include/discover_poco.php");
+
+// run the process to update locally stored global contacts in the background
+
+proc_run('php',"include/discover_poco.php", "checkcontact");
+
+// When everything else is done ...
+proc_run("php","include/poller.php");
+
 // Cleaning killed processes
 $r = q("SELECT DISTINCT(`pid`) FROM `workerqueue` WHERE `executed` != '0000-00-00 00:00:00'");
 foreach($r AS $pid)
@@ -36,9 +55,12 @@ foreach($r AS $pid)
 // Checking number of workers
 $workers = q("SELECT COUNT(*) AS `workers` FROM `workerqueue` WHERE `executed` != '0000-00-00 00:00:00'");
 
-$threads = 3;
+$queues = intval(get_config("system", "worker_queues"));
 
-if ($workers[0]["workers"] >= $threads)
+if ($queues == 0)
+       $queues = 4;
+
+if ($workers[0]["workers"] >= $queues)
        return;
 
 while ($r = q("SELECT * FROM `workerqueue` WHERE `executed` = '0000-00-00 00:00:00' ORDER BY `created` LIMIT 1")) {
@@ -58,11 +80,12 @@ while ($r = q("SELECT * FROM `workerqueue` WHERE `executed` = '0000-00-00 00:00:
 
        if (function_exists($funcname)) {
                logger("Process ".getmypid().": ".$funcname." ".$r[0]["parameter"]);
-               //$funcname($argv, $argc);
-               sleep(10);
+               $funcname($argv, $argc);
+               //sleep(10);
                logger("Process ".getmypid().": ".$funcname." - done");
 
                q("DELETE FROM `workerqueue` WHERE `id` = %d", intval($r[0]["id"]));
        }
 }
+
 ?>