From cd41397f36b1e93c63f5c8348e9b71bffc34dbf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Fri, 16 Apr 2021 15:11:52 +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 --- HttpServer/Events/OnWorkerStart.php | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/HttpServer/Events/OnWorkerStart.php b/HttpServer/Events/OnWorkerStart.php index 04054c2b..810f2032 100644 --- a/HttpServer/Events/OnWorkerStart.php +++ b/HttpServer/Events/OnWorkerStart.php @@ -36,11 +36,12 @@ class OnWorkerStart extends Callback $annotation = Snowflake::app()->getAnnotation(); $annotation->setLoader(unserialize($content)); + $annotation->runtime(directory('app')); if ($worker_id < $server->setting['worker_num']) { - $this->onWorker($server, $annotation); + $this->onWorker($server); } else { - $this->onTask($server, $annotation); + $this->onTask($server); } } @@ -58,14 +59,11 @@ class OnWorkerStart extends Callback /** * @param Server $server - * @param Annotation $annotation * @throws ConfigException * @throws Exception */ - public function onTask(Server $server, Annotation $annotation) + public function onTask(Server $server) { - $annotation->runtime(directory('app')); - putenv('environmental=' . Snowflake::TASK); name($server->worker_pid, 'Task#' . $server->worker_id); @@ -78,15 +76,11 @@ class OnWorkerStart extends Callback /** * @param Server $server - * @param Annotation $annotation * @throws Exception */ - public function onWorker(Server $server, Annotation $annotation) + public function onWorker(Server $server) { try { - $time = microtime(true); - $annotation->runtime(directory('app')); - name($server->worker_pid, 'Worker#' . $server->worker_id); Snowflake::setWorkerId($server->worker_pid);