From ab76dc0889d7b27711ee26a24e31e2dbd59dacb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Mon, 19 Apr 2021 13:32:59 +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 | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/HttpServer/Events/OnWorkerStart.php b/HttpServer/Events/OnWorkerStart.php index 8e01f747..9503f9b9 100644 --- a/HttpServer/Events/OnWorkerStart.php +++ b/HttpServer/Events/OnWorkerStart.php @@ -36,12 +36,12 @@ class OnWorkerStart extends Callback $annotation = Snowflake::app()->getAnnotation(); $annotation->setLoader(unserialize($content)); - if ($worker_id < $server->setting['worker_num']) { - $this->onWorker($server, $annotation); + if ($worker_id < $server->setting['worker_num']) { + $this->onWorker($server, $annotation); } else { $this->onTask($server, $annotation); } - } + } /** @@ -65,9 +65,9 @@ class OnWorkerStart extends Callback { putenv('environmental=' . Snowflake::TASK); - $annotation->runtime(MODEL_PATH); - $annotation->runtime(CRONTAB_PATH); - $annotation->runtime(CLIENT_PATH); + $annotation->runtime(MODEL_PATH); + $annotation->runtime(CRONTAB_PATH); + $annotation->runtime(CLIENT_PATH); name($server->worker_pid, 'Task#' . $server->worker_id); @@ -87,12 +87,14 @@ class OnWorkerStart extends Callback try { name($server->worker_pid, 'Worker#' . $server->worker_id); - $annotation->runtime(CONTROLLER_PATH); - $annotation->runtime(SOCKET_PATH); - $annotation->runtime(MODEL_PATH); - $annotation->runtime(CRONTAB_PATH); - $annotation->runtime(CLIENT_PATH); - $annotation->runtime(TASK_PATH); + $time = microtime(true); + $annotation->runtime(CONTROLLER_PATH); + $this->debug('use time.' . microtime(true) - $time); + $annotation->runtime(SOCKET_PATH); + $annotation->runtime(MODEL_PATH); + $annotation->runtime(CRONTAB_PATH); + $annotation->runtime(CLIENT_PATH); + $annotation->runtime(TASK_PATH); Snowflake::setWorkerId($server->worker_pid); putenv('environmental=' . Snowflake::WORKER);