From a943a6ca25686755d3da46f505e9cdb2dc463f3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Tue, 17 Aug 2021 18:45:22 +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 --- Server/ServerManager.php | 5 +++-- http-helper/Server.php | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Server/ServerManager.php b/Server/ServerManager.php index 138c0876..318314aa 100644 --- a/Server/ServerManager.php +++ b/Server/ServerManager.php @@ -157,7 +157,7 @@ class ServerManager * @param array $ports * @return array */ - private function sortService(array $ports): array + public function sortService(array $ports): array { $array = []; foreach ($ports as $port) { @@ -315,7 +315,8 @@ class ServerManager return; } while ($this->checkPortIsAlready($port)) { - exec('kill ' . $pid, $execResult); + exec('kill -15 ' . $pid, $execResult); + Process::kill($pid,); usleep(300); } } diff --git a/http-helper/Server.php b/http-helper/Server.php index 819e68a2..d62ded71 100644 --- a/http-helper/Server.php +++ b/http-helper/Server.php @@ -131,7 +131,7 @@ class Server extends HttpService public function shutdown() { $configs = Config::get('server', [], true); - foreach ($configs['ports'] ?? [] as $config) { + foreach ($this->manager->sortService($configs) as $config) { $this->manager->stopServer($config['port']); } $this->eventDispatch->dispatch(new OnShutdown());