public static function doJobs($timeout = 60) : bool { self::addJobs(); $maxChildren = Config::getInstance()->get("maxJobChildren", 20); $time = time() + $timeout; $redis = Redis::get(); $queueJobs = new JobQueue($redis); $children = []; while (time() <= $time) { $job = $queueJobs->pop(); $pid = $job === null ? 0 : pcntl_fork(); if ($job !== null && $pid === 0) { return self::runJob($job); } $children[$pid] = true; self::checkChildren($maxChildren, $children); } return false; }