From 751bc7cc4a4fd00a79a84e3e3c13d07398e68d4a Mon Sep 17 00:00:00 2001 From: "as2252258@163.com" Date: Sun, 29 Aug 2021 04:31:14 +0800 Subject: [PATCH] 111 --- http-server/Worker/OnWorkerStart.php | 15 ++++++++++----- note/Route/Document.php | 3 ++- note/Route/Middleware.php | 1 + note/Route/Route.php | 4 +++- note/Route/Socket.php | 1 + 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/http-server/Worker/OnWorkerStart.php b/http-server/Worker/OnWorkerStart.php index ea5d25ef..2d27c9da 100644 --- a/http-server/Worker/OnWorkerStart.php +++ b/http-server/Worker/OnWorkerStart.php @@ -55,12 +55,14 @@ class OnWorkerStart implements EventDispatcherInterface /** * @param $event * @throws \Kiri\Exception\ConfigException + * @throws \Exception */ public function onTaskInit($event) { - $this->annotation->read(APP_PATH . 'app', 'App', [CONTROLLER_PATH]); - putenv('environmental=' . Kiri::TASK); + if (is_enable_file_modification_listening()) { + $this->annotation->read(APP_PATH . 'app', 'App', [CONTROLLER_PATH]); + } echo sprintf("\033[36m[" . date('Y-m-d H:i:s') . "]\033[0m Tasker[%d].%d start.", $event->server->worker_pid, $event->workerId) . PHP_EOL; @@ -75,14 +77,17 @@ class OnWorkerStart implements EventDispatcherInterface */ public function onWorkerInit($event) { - $this->annotation->read(APP_PATH . 'app'); putenv('environmental=' . Kiri::WORKER); - echo sprintf("\033[36m[" . date('Y-m-d H:i:s') . "]\033[0m Worker[%d].%d start.", $event->server->worker_pid, $event->workerId) . PHP_EOL; - $this->setProcessName(sprintf('Worker[%d].%d', $event->server->worker_pid, $event->workerId)); + if (is_enable_file_modification_listening()) { + $this->annotation->read(APP_PATH . 'app'); $loader = Kiri::app()->getRouter(); $loader->_loader(); } + + echo sprintf("\033[36m[" . date('Y-m-d H:i:s') . "]\033[0m Worker[%d].%d start.", $event->server->worker_pid, $event->workerId) . PHP_EOL; + + $this->setProcessName(sprintf('Worker[%d].%d', $event->server->worker_pid, $event->workerId)); } diff --git a/note/Route/Document.php b/note/Route/Document.php index e8ee56db..0114cc65 100644 --- a/note/Route/Document.php +++ b/note/Route/Document.php @@ -32,7 +32,8 @@ use Annotation\Attribute; /** - * @param mixed $class + * @param static $params + * @param mixed $class * @param mixed|null $method * @return array */ diff --git a/note/Route/Middleware.php b/note/Route/Middleware.php index ad17b8dc..a2d71896 100644 --- a/note/Route/Middleware.php +++ b/note/Route/Middleware.php @@ -28,6 +28,7 @@ use Http\IInterface\MiddlewareInterface; /** + * @param static $params * @param mixed $class * @param mixed|null $method * @return $this diff --git a/note/Route/Route.php b/note/Route/Route.php index dc895d16..ebab2cb4 100644 --- a/note/Route/Route.php +++ b/note/Route/Route.php @@ -24,10 +24,12 @@ use Kiri\Kiri; /** + * @param static $params * @param mixed $class * @param mixed|null $method * @return Router - * @throws Exception + * @throws \Kiri\Exception\NotFindClassException + * @throws \ReflectionException */ public static function execute(mixed $params, mixed $class, mixed $method = null): Router { diff --git a/note/Route/Socket.php b/note/Route/Socket.php index efdf7dfb..0caf2741 100644 --- a/note/Route/Socket.php +++ b/note/Route/Socket.php @@ -32,6 +32,7 @@ use Kiri\Kiri; /** + * @param static $params * @param mixed $class * @param mixed|null $method * @return Router