]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/Worker.php
Create Core\Process as a base for followup work
[friendica.git] / src / Core / Worker.php
index ffca31ddfd9c03035ece782b2e7ba976ddee656f..037590c90d7783e025bdf492353114b34972bb73 100644 (file)
@@ -5,6 +5,7 @@
 namespace Friendica\Core;
 
 use Friendica\BaseObject;
+use Friendica\Core;
 use Friendica\Database\DBA;
 use Friendica\Model\Process;
 use Friendica\Util\DateTimeFormat;
@@ -186,7 +187,7 @@ class Worker
        private static function deferredEntries()
        {
                $stamp = (float)microtime(true);
-               $count = DBA::count('workerqueue', ["NOT `done` AND `pid` = 0 AND `next_try` > ?", DateTimeFormat::utcNow()]);
+               $count = DBA::count('workerqueue', ["NOT `done` AND `pid` = 0 AND `retrial` > ?", 0]);
                self::$db_duration += (microtime(true) - $stamp);
                self::$db_duration_count += (microtime(true) - $stamp);
                return $count;
@@ -686,10 +687,8 @@ class Worker
                                        DBA::close($processes);
                                }
                                DBA::close($jobs);
-                               $entries = $deferred + $waiting_processes;
                        } else {
-                               $entries = self::totalEntries();
-                               $waiting_processes = max(0, $entries - $deferred);
+                               $waiting_processes =  self::totalEntries();
                                $stamp = (float)microtime(true);
                                $jobs = DBA::p("SELECT COUNT(*) AS `running`, `priority` FROM `process` INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid` AND NOT `done` GROUP BY `priority` ORDER BY `priority`");
                                self::$db_duration += (microtime(true) - $stamp);
@@ -1084,7 +1083,9 @@ class Worker
 
                $args = ['no_cron' => !$do_cron];
 
-               get_app()->proc_run($command, $args);
+               $a = get_app();
+               $process = new Core\Process($a->getLogger(), $a->getMode(), $a->getConfig(), $a->getBasePath());
+               $process->run($command, $args);
 
                // after spawning we have to remove the flag.
                if (Config::get('system', 'worker_daemon_mode', false)) {
@@ -1126,7 +1127,7 @@ class Worker
 
                $priority = PRIORITY_MEDIUM;
                // Don't fork from frontend tasks by default
-               $dont_fork = Config::get("system", "worker_dont_fork", false) || !\get_app()->isBackend();
+               $dont_fork = Config::get("system", "worker_dont_fork", false) || !\get_app()->getMode()->isBackend();
                $created = DateTimeFormat::utcNow();
                $force_priority = false;