config->get('daemonMaxProcessNumber'); $interval = $this->config->get('daemonInterval'); $timeout = $this->config->get('daemonProcessTimeout'); $phpExecutablePath = $this->config->get('phpExecutablePath'); if (!$phpExecutablePath) { $phpExecutablePath = (new PhpExecutableFinder)->find(); } if (!$maxProcessNumber || !$interval) { $this->log->error("Daemon config params are not set."); return; } $processList = []; while (true) { /** @phpstan-ignore-line */ $toSkip = false; $runningCount = 0; foreach ($processList as $i => $process) { if ($process->isRunning()) { $runningCount++; } else { unset($processList[$i]); } } $processList = array_values($processList); if ($runningCount >= $maxProcessNumber) { $toSkip = true; } if (!$toSkip) { $process = new Process([$phpExecutablePath, 'cron.php']); $process->setTimeout($timeout); $process->start(); $processList[] = $process; } sleep($interval); } } }