]> git.mxchange.org Git - friendica.git/commitdiff
Fixed code structure
authorMichael <heluecht@pirati.ca>
Fri, 20 May 2022 04:42:10 +0000 (04:42 +0000)
committerMichael <heluecht@pirati.ca>
Fri, 20 May 2022 04:42:10 +0000 (04:42 +0000)
src/Core/Worker/Cron.php
src/Core/Worker/Daemon.php
src/Core/Worker/IPC.php
src/Protocol/ActivityPub/Delivery.php

index b07c47275054a13d8a249739d86915ad397d5c62..da9e16d42fc41bff30b56ec3bba34e4e282c02b6 100644 (file)
@@ -68,7 +68,6 @@ class Cron
         */
        public static function killStaleWorkers()
        {
-               $stamp = (float)microtime(true);
                $entries = DBA::select(
                        'workerqueue',
                        ['id', 'pid', 'executed', 'priority', 'command', 'parameter'],
@@ -78,7 +77,6 @@ class Cron
 
                while ($entry = DBA::fetch($entries)) {
                        if (!posix_kill($entry["pid"], 0)) {
-                               $stamp = (float)microtime(true);
                                DBA::update(
                                        'workerqueue',
                                        ['executed' => DBA::NULL_DATETIME, 'pid' => 0],
@@ -89,7 +87,7 @@ class Cron
 
                                // Define the maximum durations
                                $max_duration_defaults = [PRIORITY_CRITICAL => 720, PRIORITY_HIGH => 10, PRIORITY_MEDIUM => 60, PRIORITY_LOW => 180, PRIORITY_NEGLIGIBLE => 720];
-                               $max_duration = $max_duration_defaults[$entry['priority']];
+                               $max_duration          = $max_duration_defaults[$entry['priority']];
 
                                $argv = json_decode($entry['parameter'], true);
                                if (!empty($entry['command'])) {
@@ -119,7 +117,6 @@ class Cron
                                        } elseif ($entry['priority'] != PRIORITY_CRITICAL) {
                                                $new_priority = PRIORITY_NEGLIGIBLE;
                                        }
-                                       $stamp = (float)microtime(true);
                                        DBA::update(
                                                'workerqueue',
                                                ['executed' => DBA::NULL_DATETIME, 'created' => DateTimeFormat::utcNow(), 'priority' => $new_priority, 'pid' => 0],
@@ -154,11 +151,11 @@ class Cron
                                DI::lock()->release(Worker::LOCK_PROCESS);
                        }
                }
-       }       
+       }
 
        /**
         * Directly deliver AP messages or requeue them.
-        * 
+        *
         * This function is placed here as a safeguard. Even when the worker queue is completely blocked, messages will be delivered.
         */
        private static function deliverPosts()
index afc6cda4ecb13641125a152b433690206593538b..02c37d3b0d38e78d700f5e7ef2f35259b86e0016 100644 (file)
@@ -70,7 +70,7 @@ class Daemon
                        return false;
                }
 
-               $pid = intval(file_get_contents($pidfile));
+               $pid     = intval(file_get_contents($pidfile));
                $running = posix_kill($pid, 0);
 
                self::$daemon_mode = $running;
@@ -129,9 +129,7 @@ class Daemon
        private static function spawn()
        {
                Logger::notice('Starting new daemon process');
-               $command = 'bin/daemon.php';
-               $a = DI::app();
-               DI::system()->run($command, ['start']);
+               DI::system()->run('bin/daemon.php', ['start']);
                Logger::notice('New daemon process started');
        }
 }
index a10cf1cd0c7a1d9673d62d6ed011eb87767d2be7..0da63b8b88525c18eb51cc7a9fa43a63a5db510f 100644 (file)
@@ -62,7 +62,6 @@ class IPC
         */
        public static function JobsExists(int $key = 0)
        {
-               $stamp = (float)microtime(true);
                $row = DBA::selectFirst('worker-ipc', ['jobs'], ['key' => $key]);
 
                // When we don't have a row, no job is running
index 29fe21dd0694b2e78e997c4a8760e2ed564a6536..2a2a63fee148f5188f4f3bcb503d2ec45f0dbc66 100644 (file)
@@ -32,7 +32,7 @@ use Friendica\Worker\Delivery as WorkerDelivery;
 
 class Delivery
 {
-       public static function deliver(string $inbox):array
+       public static function deliver(string $inbox): array
        {
                $uri_ids    = [];
                $posts      = Post\Delivery::selectForInbox($inbox);