From f849348858c4f5365f17507254d6e7cd8e9dbd72 Mon Sep 17 00:00:00 2001 From: "as2252258@163.com" Date: Sat, 27 Feb 2021 03:25:48 +0800 Subject: [PATCH] modify --- HttpServer/Events/OnWorkerStart.php | 5 ++--- System/Snowflake.php | 8 ++++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/HttpServer/Events/OnWorkerStart.php b/HttpServer/Events/OnWorkerStart.php index b9a08efe..d6a133b8 100644 --- a/HttpServer/Events/OnWorkerStart.php +++ b/HttpServer/Events/OnWorkerStart.php @@ -56,7 +56,6 @@ class OnWorkerStart extends Callback } - /** * @param Server $server * @param int $workerId @@ -65,14 +64,14 @@ class OnWorkerStart extends Callback public function onTaskSignal(Server $server, int $workerId) { try { - $sigkill = Coroutine::waitSignal(SIGKILL | SIGUSR1); + $sigkill = Coroutine::waitSignal(SIGTERM | SIGKILL | SIGUSR2 | SIGUSR1); var_dump($sigkill); if ($sigkill !== false) { while (Snowflake::app()->isRun()) { Coroutine::sleep(1); } } - $server->stop($workerId); + $server->stop(); } catch (\Throwable $exception) { $this->addError($exception); } diff --git a/System/Snowflake.php b/System/Snowflake.php index b782c2ff..ffd8799a 100644 --- a/System/Snowflake.php +++ b/System/Snowflake.php @@ -244,9 +244,9 @@ class Snowflake */ public static function getMasterPid(): bool|string { - $default = APP_PATH . 'storage/server.pid'; - $server = Config::get('settings.pid_file', false, $default); - return file_get_contents($server); + $pid = Snowflake::app()->getSwoole()->setting['pid_file']; + + return file_get_contents($pid); } @@ -389,7 +389,7 @@ class Snowflake */ public static function reload(): mixed { - return Process::kill((int)Snowflake::app()->getSwoole()->getMasterPid(),SIGUSR1); + return Process::kill((int)Snowflake::getMasterPid(),SIGUSR1); }