diff --git a/Handler/OnServerWorker.php b/Handler/OnServerWorker.php index 70443bd..cf38020 100644 --- a/Handler/OnServerWorker.php +++ b/Handler/OnServerWorker.php @@ -36,7 +36,7 @@ class OnServerWorker extends \Kiri\Server\Abstracts\Server */ public function init() { - $this->collector = Kiri::getDi()->get(Router::class); +// $this->collector = Kiri::getDi()->get(Router::class); } @@ -52,7 +52,6 @@ class OnServerWorker extends \Kiri\Server\Abstracts\Server set_env('environmental_workerId', $workerId); if ($workerId < $server->setting['worker_num']) { $this->setProcessName(sprintf('Worker[%d].%d', $server->worker_pid, $workerId)); - $this->collector->scan_build_route(); $dispatch->dispatch(new OnWorkerStart($server, $workerId)); set_env('environmental', Kiri::WORKER); } else { diff --git a/Server.php b/Server.php index a0aab93..e0c4fc8 100644 --- a/Server.php +++ b/Server.php @@ -17,6 +17,7 @@ use Psr\Container\ContainerExceptionInterface; use Psr\Container\NotFoundExceptionInterface; use ReflectionException; use Swoole\Coroutine; +use Kiri\Message\Handler\Router; defined('PID_PATH') or define('PID_PATH', APP_PATH . 'storage/server.pid'); @@ -81,6 +82,7 @@ class Server extends HttpService * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface * @throws ReflectionException + * @throws Exception */ public function start(): void { @@ -97,6 +99,8 @@ class Server extends HttpService $this->getEventDispatch()->dispatch(new OnServerBeforeStart()); + $this->getContainer()->get(Router::class)->scan_build_route(); + $this->manager->start(); }