From 9ad16e7d700ea24ded663fee69ff1c1ab2dc6e37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Tue, 5 Jan 2021 10:15:33 +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 | 3 ++- System/Process/Process.php | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/HttpServer/Events/OnWorkerStart.php b/HttpServer/Events/OnWorkerStart.php index 2d81c478..29e35e49 100644 --- a/HttpServer/Events/OnWorkerStart.php +++ b/HttpServer/Events/OnWorkerStart.php @@ -35,11 +35,12 @@ class OnWorkerStart extends Callback swoole_set_process_name($get_name); } - putenv('workerId=' . $worker_id); if ($worker_id >= $server->setting['worker_num']) { fire(Event::SERVER_TASK_START); + putenv('workerId=Task.' . $worker_id); return; } + putenv('workerId=Worker.' . $worker_id); Snowflake::setWorkerId($server->worker_pid); $this->setWorkerAction($worker_id); } diff --git a/System/Process/Process.php b/System/Process/Process.php index e91bfd4b..dfd1a1aa 100644 --- a/System/Process/Process.php +++ b/System/Process/Process.php @@ -33,6 +33,7 @@ abstract class Process extends \Swoole\Process implements SProcess $class = get_called_class(); parent::__construct(function ($process) use ($name, $class) { fire(Event::SERVER_WORKER_START); + putenv('workerId=Process.0'); if (Snowflake::isLinux()) { $prefix = ucfirst(rtrim(Snowflake::app()->id, ':')); $this->name($prefix . ': ' . $class);