/** * 创建子进程 * @return void */ protected static function forkWorkers() { /** @var static $worker */ foreach (self::$_workers as $worker) { // 启动过程中需要得到运行用户名的最大长度,在status时格式化展示 if (self::$_status === self::STATUS_STARTING) { if (empty($worker->name)) { $worker->name = $worker->getSocketName(); } $worker_name_length = strlen($worker->name); if (self::$_maxWorkerNameLength < $worker_name_length) { self::$_maxWorkerNameLength = $worker_name_length; } } // 创建子进程 while (count(self::$_pidMap[$worker->workerId]) < $worker->count) { static::forkOneWorker($worker); } } }