From 908c8719d374956a24edc29e025de8edcde4dbca Mon Sep 17 00:00:00 2001 From: whwyy Date: Wed, 24 Jun 2026 20:17:54 +0800 Subject: [PATCH] eee --- ServerCommand.php | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/ServerCommand.php b/ServerCommand.php index ef771ea..490fa6f 100644 --- a/ServerCommand.php +++ b/ServerCommand.php @@ -125,22 +125,23 @@ class ServerCommand extends Command } - /** - * @param InputInterface $input - * @return int - * @throws - */ - protected function start(InputInterface $input): int - { - $this->asyncServer->addProcess(config('process', [])); - if (\config('servers.reload.hot', false) === true) { - $this->asyncServer->addProcess([FileWatcher::class]); - } else { - di(Router::class)->scan_build_route(); - } - $this->asyncServer->initCoreServers(config('servers.server', []), (int)$input->getOption('daemon')); - $this->asyncServer->start(); - return 1; - } + /** + * @param InputInterface $input + * @return int + * @throws + */ + protected function start(InputInterface $input): int + { + $this->asyncServer->addProcess(config('process', [])); + if (\config('servers.reload.hot', false) === true) { + $this->asyncServer->addProcess([FileWatcher::class]); + } + // Master 进程在 fork 前完成首次扫描,Worker 启动时不再重复全量扫描 + // 避免每个 Worker 独立执行 opcache_compile_file + invalidateClasses 造成 OOM + di(Router::class)->scan_build_route(); + $this->asyncServer->initCoreServers(config('servers.server', []), (int)$input->getOption('daemon')); + $this->asyncServer->start(); + return 1; + } }