From 128708825da79312e123e256c26c55f61a26c6ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Fri, 26 Feb 2021 20:12:07 +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 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/HttpServer/Events/OnWorkerStart.php b/HttpServer/Events/OnWorkerStart.php index 8f7ca8f7..097d59b2 100644 --- a/HttpServer/Events/OnWorkerStart.php +++ b/HttpServer/Events/OnWorkerStart.php @@ -42,8 +42,6 @@ class OnWorkerStart extends Callback swoole_set_process_name($get_name); } - Snowflake::app()->stateInit(); - putenv('workerId=' . ($worker_id >= $server->setting['worker_num'] ? 'Task' : 'Worker') . '.' . $worker_id); if ($worker_id >= $server->setting['worker_num']) { fire(Event::SERVER_TASK_START); @@ -64,6 +62,9 @@ class OnWorkerStart extends Callback public function onTaskSignal(Server $server, int $workerId): mixed { $sigkill = Coroutine::waitSignal(SIGTERM | SIGKILL | SIGUSR2 | SIGUSR1, -1); + Coroutine\defer(function () { + Snowflake::app()->stateInit(); + }); if ($sigkill === false) { return $server->stop($workerId); }