From 78f67c1e0ef699d47966b2560f6e43eb5e63ddc0 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 1 Jan 2021 23:10:38 +0000 Subject: [PATCH] Check for reaching the memory limit --- src/Core/Worker.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Core/Worker.php b/src/Core/Worker.php index e90747e41a..009912ee7f 100644 --- a/src/Core/Worker.php +++ b/src/Core/Worker.php @@ -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(),