]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/Worker.php
Merge pull request #6430 from tobiasd/20190112-lng
[friendica.git] / src / Core / Worker.php
index c053e32bc8859a25e1b32b0aabf6ab73d0f9bdbb..3a4be04381b754401d664e561210224fdee3b8e4 100644 (file)
@@ -11,8 +11,6 @@ use Friendica\Model\Process;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Network;
 
-require_once 'include/dba.php';
-
 /**
  * @file src/Core/Worker.php
  *
@@ -37,7 +35,7 @@ class Worker
         */
        public static function processQueue($run_cron = true)
        {
-               $a = get_app();
+               $a = \get_app();
 
                self::$up_start = microtime(true);
 
@@ -208,7 +206,7 @@ class Worker
         */
        public static function execute($queue)
        {
-               $a = get_app();
+               $a = \get_app();
 
                $mypid = getmypid();
 
@@ -321,7 +319,7 @@ class Worker
         */
        private static function execFunction($queue, $funcname, $argv, $method_call)
        {
-               $a = get_app();
+               $a = \get_app();
 
                $mypid = getmypid();
 
@@ -668,9 +666,10 @@ class Worker
                                DBA::close($processes);
 
                                // Now adding all processes with workerqueue entries
-                               $entries = DBA::p("SELECT COUNT(*) AS `entries`, `priority` FROM `workerqueue` WHERE NOT `done` GROUP BY `priority`");
+                               $entries = DBA::p("SELECT COUNT(*) AS `entries`, `priority` FROM `workerqueue` WHERE NOT `done` AND `next_try` < ? GROUP BY `priority`", DateTimeFormat::utcNow());
                                while ($entry = DBA::fetch($entries)) {
-                                       $processes = DBA::p("SELECT COUNT(*) AS `running` FROM `process` INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid` AND NOT `done` WHERE `priority` = ?", $entry["priority"]);
+                                       $processes = DBA::p("SELECT COUNT(*) AS `running` FROM `process` INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid` WHERE NOT `done` AND `next_try` < ? AND `priority` = ?",
+                                               DateTimeFormat::utcNow(), $entry["priority"]);
                                        if ($process = DBA::fetch($processes)) {
                                                $listitem[$entry["priority"]] = $entry["priority"].":".$process["running"]."/".$entry["entries"];
                                        }