This commit is contained in:
2026-06-24 20:17:54 +08:00
parent 69b845d924
commit 908c8719d3
+18 -17
View File
@@ -125,22 +125,23 @@ class ServerCommand extends Command
} }
/** /**
* @param InputInterface $input * @param InputInterface $input
* @return int * @return int
* @throws * @throws
*/ */
protected function start(InputInterface $input): int protected function start(InputInterface $input): int
{ {
$this->asyncServer->addProcess(config('process', [])); $this->asyncServer->addProcess(config('process', []));
if (\config('servers.reload.hot', false) === true) { if (\config('servers.reload.hot', false) === true) {
$this->asyncServer->addProcess([FileWatcher::class]); $this->asyncServer->addProcess([FileWatcher::class]);
} else { }
di(Router::class)->scan_build_route(); // Master 进程在 fork 前完成首次扫描,Worker 启动时不再重复全量扫描
} // 避免每个 Worker 独立执行 opcache_compile_file + invalidateClasses 造成 OOM
$this->asyncServer->initCoreServers(config('servers.server', []), (int)$input->getOption('daemon')); di(Router::class)->scan_build_route();
$this->asyncServer->start(); $this->asyncServer->initCoreServers(config('servers.server', []), (int)$input->getOption('daemon'));
return 1; $this->asyncServer->start();
} return 1;
}
} }