From 0ae525c86ecaff768bcb0e8ca09260d3f134182b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Wed, 21 Oct 2020 15:55:56 +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/OnShutdown.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/HttpServer/Events/OnShutdown.php b/HttpServer/Events/OnShutdown.php index 7fe7f809..ecc39f31 100644 --- a/HttpServer/Events/OnShutdown.php +++ b/HttpServer/Events/OnShutdown.php @@ -34,6 +34,18 @@ class OnShutdown extends Callback public function onHandler(Server $server) { $this->debug('server shutdown~'); + + $workers = glob(storage(null, 'worker') . '/*'); + foreach ($workers as $worker) { + $content = file_get_contents($worker); + posix_kill($content, 9); + } + + $content = '[error]: ' . date('Y-m-d H:i:s') . PHP_EOL; + $content .= print_r(swoole_last_error(), true); + + Snowflake::writeFile(storage('shutdown.log'), $content, FILE_APPEND); + $this->system_mail('server shutdown~'); $event = Snowflake::app()->getEvent(); $event->trigger(Event::SERVER_SHUTDOWN);