]> git.mxchange.org Git - friendica.git/blobdiff - bin/daemon.php
Convert to tabs
[friendica.git] / bin / daemon.php
index fcdd735668cf042550a3f598c6311419a7c70431..1682d366ede0ca16fd05c3ab8f0df7bd04b13a0a 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/env php
 <?php
 /**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2022, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
  * You should have received a copy of the GNU Affero General Public License
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  *
+ */
+
+/**
  * Run the worker from a daemon.
  *
  * This script was taken from http://php.net/manual/en/function.pcntl-fork.php
  */
-
 if (php_sapi_name() !== 'cli') {
        header($_SERVER["SERVER_PROTOCOL"] . ' 403 Forbidden');
        exit();
@@ -60,6 +62,7 @@ $dice = (new Dice())->addRules(include __DIR__ . '/../static/dependencies.config
 $dice = $dice->addRule(LoggerInterface::class,['constructParams' => ['daemon']]);
 
 DI::init($dice);
+\Friendica\Core\Logger\Handler\ErrorHandler::register($dice->create(\Psr\Log\LoggerInterface::class));
 $a = DI::app();
 
 if (DI::mode()->isInstall()) {
@@ -195,7 +198,7 @@ while (true) {
                $do_cron = true;
        }
 
-       if ($do_cron || (!DI::process()->isMaxLoadReached() && Worker::entriesExists() && Worker::isReady())) {
+       if ($do_cron || (!DI::system()->isMaxLoadReached() && Worker::entriesExists() && Worker::isReady())) {
                Worker::spawnWorker($do_cron);
        } else {
                Logger::info('Cool down for 5 seconds', ['pid' => $pid]);
@@ -229,7 +232,7 @@ while (true) {
                }
 
                $timeout = ($seconds >= $wait_interval);
-       } while (!$timeout && !Worker::IPCJobsExists());
+       } while (!$timeout && !Worker\IPC::JobsExists());
 
        if ($timeout) {
                $do_cron = true;