]> git.mxchange.org Git - friendica.git/commitdiff
Check for reaching the memory limit
authorMichael <heluecht@pirati.ca>
Fri, 1 Jan 2021 23:10:38 +0000 (23:10 +0000)
committerMichael <heluecht@pirati.ca>
Fri, 1 Jan 2021 23:10:38 +0000 (23:10 +0000)
src/Core/Worker.php

index e90747e41a1a9bd04bb2b98f5648ccc962565605..009912ee7fa63cb277b72964913c13a2319a1b3a 100644 (file)
@@ -1189,6 +1189,11 @@ class Worker
         */
        private static function forkProcess(bool $do_cron)
        {
+               if (DI::process()->isMinMemoryReached()) {
+                       Logger::warning('Memory limit reached - quitting');
+                       return;
+               }
+
                // Children inherit their parent's database connection.
                // To avoid problems we disconnect and connect both parent and child
                DBA::disconnect();
@@ -1230,7 +1235,7 @@ class Worker
        {
                // Worker and daemon are started from the command line.
                // This means that this is executed by a PHP interpreter without runtime limitations
-               if (in_array(DI::mode()->getExecutor(), [Mode::DAEMON, Mode::WORKER])) {
+               if (function_exists('pcntl_fork') && in_array(DI::mode()->getExecutor(), [Mode::DAEMON, Mode::WORKER])) {
                        self::forkProcess($do_cron);
                } else {
                        $process = new Core\Process(DI::logger(), DI::mode(), DI::config(),