From 1f20e88cdda877c742f93e9f47baa50e1f3dab86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Tue, 3 Aug 2021 10:25:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Server/Worker/ServerWorker.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Server/Worker/ServerWorker.php b/Server/Worker/ServerWorker.php index c33cd6a9..12cf2c31 100644 --- a/Server/Worker/ServerWorker.php +++ b/Server/Worker/ServerWorker.php @@ -42,6 +42,11 @@ class ServerWorker extends \Server\Abstracts\Server $this->runEvent(Constant::WORKER_START, null, [$server, $workerId]); + putenv('environmental=' . Snowflake::WORKER); + if ($workerId > $server->setting['worker_num']) { + putenv('environmental=' . Snowflake::TASK); + } + $this->workerInitExecutor($server, $annotation, $workerId); $this->interpretDirectory($annotation); @@ -50,16 +55,20 @@ class ServerWorker extends \Server\Abstracts\Server /** - * @param $annotation + * @param Annotation $annotation * @throws ReflectionException * @throws NotFindClassException + * @throws Exception */ - private function interpretDirectory($annotation) + private function interpretDirectory(Annotation $annotation) { $fileLists = $annotation->runtime(APP_PATH . 'app'); $di = Snowflake::getDi(); - foreach ($fileLists as $class) { + foreach ($fileLists as $file => $class) { + if (!Snowflake::isWorker() && str_contains($file, CONTROLLER_PATH)) { + continue; + } $instance = $di->get($class); $methods = $di->getMethodAttribute($class); foreach ($methods as $method => $attribute) {