From e0203e2ccd51de5db08a458b376c7a003d1ef06e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Wed, 19 Apr 2023 13:38:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Abstracts/AsyncServer.php | 6 +----- HotReload.php | 8 ++++---- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/Abstracts/AsyncServer.php b/Abstracts/AsyncServer.php index 24b6fd8..85f513e 100644 --- a/Abstracts/AsyncServer.php +++ b/Abstracts/AsyncServer.php @@ -50,11 +50,7 @@ class AsyncServer implements ServerInterface public function initCoreServers(array $service, int $daemon = 0): void { $service = $this->genConfigService($service); - $pid = (int)file_get_contents(storage('.swoole.pid')); - if (posix_kill($pid, 0)) { - posix_kill($pid, SIGTERM); - } - + $this->createBaseServer(array_shift($service), $daemon); foreach ($service as $value) { $this->addListener($value); diff --git a/HotReload.php b/HotReload.php index 8c7cf13..342fcfc 100644 --- a/HotReload.php +++ b/HotReload.php @@ -50,10 +50,11 @@ class HotReload extends Command protected function execute(InputInterface $input, OutputInterface $output) { $this->startProcess(); - $signal = SIGINT | SIGQUIT | SIGTERM; - $bool = Process::signal($signal, function () { + $bool = pcntl_signal(SIGINT | SIGQUIT | SIGTERM, function () { $this->stopProcess(); - Process::wait(); + + $pid = (int)file_get_contents(storage('.swoole.pid')); + pcntl_waitpid($pid, $status); }); echo 'Listen signal ' . ($bool ? 'success' : 'fail') . PHP_EOL; if (extension_loaded('inotify')) { @@ -61,7 +62,6 @@ class HotReload extends Command } else { $this->onCrontabReload(); } - Process::wait(); }