]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/Worker/Daemon.php
Merge remote-tracking branch 'upstream/develop' into inbox-gsid
[friendica.git] / src / Core / Worker / Daemon.php
index 02c37d3b0d38e78d700f5e7ef2f35259b86e0016..92fc28c011b6011aa7ed53b0dd78b0f3d967b5ce 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2022, the Friendica project
+ * @copyright Copyright (C) 2010-2023, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -30,7 +30,7 @@ use Friendica\DI;
  */
 class Daemon
 {
-       private static $daemon_mode = null;
+       private static $mode = null;
 
        /**
         * Checks if the worker is running in the daemon mode.
@@ -39,41 +39,41 @@ class Daemon
         */
        public static function isMode()
        {
-               if (!is_null(self::$daemon_mode)) {
-                       return self::$daemon_mode;
+               if (!is_null(self::$mode)) {
+                       return self::$mode;
                }
 
                if (DI::mode()->getExecutor() == Mode::DAEMON) {
                        return true;
                }
 
-               $daemon_mode = DI::config()->get('system', 'worker_daemon_mode', false, true);
+               $daemon_mode = DI::keyValue()->get('worker_daemon_mode') ?? false;
                if ($daemon_mode) {
                        return $daemon_mode;
                }
 
                if (!function_exists('pcntl_fork')) {
-                       self::$daemon_mode = false;
+                       self::$mode = false;
                        return false;
                }
 
                $pidfile = DI::config()->get('system', 'pidfile');
                if (empty($pidfile)) {
                        // No pid file, no daemon
-                       self::$daemon_mode = false;
+                       self::$mode = false;
                        return false;
                }
 
                if (!is_readable($pidfile)) {
                        // No pid file. We assume that the daemon had been intentionally stopped.
-                       self::$daemon_mode = false;
+                       self::$mode = false;
                        return false;
                }
 
                $pid     = intval(file_get_contents($pidfile));
                $running = posix_kill($pid, 0);
 
-               self::$daemon_mode = $running;
+               self::$mode = $running;
                return $running;
        }
 
@@ -93,11 +93,11 @@ class Daemon
                }
 
                // Check every minute if the daemon is running
-               if (DI::config()->get('system', 'last_daemon_check', 0) + 60 > time()) {
+               if ((DI::keyValue()->get('last_daemon_check') ?? 0) + 60 > time()) {
                        return;
                }
 
-               DI::config()->set('system', 'last_daemon_check', time());
+               DI::keyValue()->set('last_daemon_check', time());
 
                $pidfile = DI::config()->get('system', 'pidfile');
                if (empty($pidfile)) {