From 1437a072c98d2cd3a4df2ef508c3ea4de395e0e8 Mon Sep 17 00:00:00 2001 From: "as2252258@163.com" Date: Sat, 27 Feb 2021 04:32:11 +0800 Subject: [PATCH] modify --- HttpServer/Events/OnWorkerStart.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/HttpServer/Events/OnWorkerStart.php b/HttpServer/Events/OnWorkerStart.php index 3b0b177b..41d078bf 100644 --- a/HttpServer/Events/OnWorkerStart.php +++ b/HttpServer/Events/OnWorkerStart.php @@ -41,19 +41,17 @@ class OnWorkerStart extends Callback if (!empty($get_name) && !Snowflake::isMac()) { swoole_set_process_name($get_name); } - Coroutine\go(function () use ($server, $worker_id) { - + Coroutine\go(function ($server, $worker_id) { $sigkill = Coroutine::waitSignal(SIGTERM | SIGKILL | SIGUSR2 | SIGUSR1); if ($sigkill !== false) { - do { - if (!Snowflake::app()->isRun()) { - break; - } - Coroutine::sleep(0.01); - } while (true); + return $server->stop(); } - $server->stop();; - }); + while (Snowflake::app()->isRun()) { + Coroutine::sleep(0.01); + } + return $server->stop(); + }, $server, $worker_id); + $name = ($worker_id >= $server->setting['worker_num'] ? 'Task' : 'Worker'); $this->debug(sprintf($name . ' #%d is start.....', $worker_id));