From 1bdbca2568c9ce7fffd74ce75c3e956830d01ef6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Mon, 14 Feb 2022 10:55:56 +0800 Subject: [PATCH] modify plugin name --- Coroutine/Http.php | 15 ++++++++++++++- Server.php | 6 +++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Coroutine/Http.php b/Coroutine/Http.php index 6ff0dbb..9e6c2f5 100644 --- a/Coroutine/Http.php +++ b/Coroutine/Http.php @@ -4,6 +4,7 @@ namespace Kiri\Server\Coroutine; use Kiri\Abstracts\Component; use Kiri\Exception\ConfigException; +use Kiri\Message\Handler\Router; use Kiri\Server\Constant; use Kiri\Server\ProcessManager; use Kiri\Server\TraitServer; @@ -30,6 +31,15 @@ class Http extends Component private array $configs = []; + public Router $collector; + + + public function init() + { + $this->collector = \Kiri::getDi()->get(Router::class); + } + + /** * @return void * @throws ContainerExceptionInterface @@ -89,7 +99,7 @@ class Http extends Component public function initBaseServer(array $config, $daemon) { $this->configs = $config; - foreach ($config as $value) { + foreach ($config['port'] as $value) { $this->_addListener($value); } } @@ -191,6 +201,9 @@ class Http extends Component { run(function () { $this->startTaskWorker($this->configs); + + $this->collector->scan_build_route(); + foreach ($this->servers as $value) { Coroutine::create(function () use ($value) { $value->start(); diff --git a/Server.php b/Server.php index aea2859..dc23ce7 100644 --- a/Server.php +++ b/Server.php @@ -11,9 +11,9 @@ use Kiri\Annotation\Inject; use Kiri\Events\EventDispatch; use Kiri\Exception\ConfigException; use Kiri\Message\Handler\Abstracts\HttpService; +use Kiri\Server\Events\OnServerBeforeStart; use Kiri\Server\Events\OnShutdown; use Psr\Container\ContainerExceptionInterface; -use Kiri\Server\Events\OnServerBeforeStart; use Psr\Container\NotFoundExceptionInterface; use ReflectionException; use Swoole\Coroutine; @@ -83,7 +83,7 @@ class Server extends HttpService * @throws ReflectionException * @throws Exception */ - public function start(): mixed + public function start(): void { $this->manager->initBaseServer(Config::get('server', [], true), $this->daemon); @@ -99,7 +99,7 @@ class Server extends HttpService $this->getEventDispatch()->dispatch(new OnServerBeforeStart()); - return $this->manager->start(); + $this->manager->start(); }