From f036bd19afcf90ea529a7d857bca5bcfbc6ce119 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Tue, 2 Mar 2021 13:36:33 +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/Action.php | 12 ++++++------ HttpServer/Server.php | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/HttpServer/Action.php b/HttpServer/Action.php index cb976169..0df9e3d3 100644 --- a/HttpServer/Action.php +++ b/HttpServer/Action.php @@ -56,9 +56,9 @@ trait Action return; } $content = file_get_contents($pid_file); - $output = Coroutine\System::exec("ps -ef $content | grep $content"); + exec("ps -ef $content | grep $content", $output); if (!empty($output)) { - Coroutine\System::exec("kill -15 $content"); + exec("kill -15 $content"); } $this->close($server); } @@ -108,7 +108,7 @@ trait Action } foreach ($files as $file) { $content = file_get_contents($file->getRealPath()); - $output = Coroutine\System::exec("ps -ax | awk '{ print $1 }' | grep -e '^{$content}$'"); + exec("ps -ax | awk '{ print $1 }' | grep -e '^{$content}$'", $output); if (count($output) > 0) { $this->closeByPid($content); } else { @@ -138,9 +138,9 @@ trait Action return false; } if (Snowflake::isLinux()) { - $output = Coroutine\System::exec('netstat -tunlp | grep ' . $port); + exec('netstat -tunlp | grep ' . $port, $output); } else { - $output = Coroutine\System::exec('lsof -i :' . $port . ' | grep -i "LISTEN"'); + exec('lsof -i :' . $port . ' | grep -i "LISTEN"', $output); } if (empty($output)) { return false; @@ -154,7 +154,7 @@ trait Action */ private function closeByPid($pid) { - Coroutine\System::exec("ps -ef | grep $pid | grep -v grep | grep -v kill + exec("ps -ef | grep $pid | grep -v grep | grep -v kill if [ $? -eq 0 ];then kill -9 `ps -ef | grep $pid | grep -v grep | grep -v kill | awk '{print $2}'` else diff --git a/HttpServer/Server.php b/HttpServer/Server.php index 7f6b1b4e..b5f8b97a 100644 --- a/HttpServer/Server.php +++ b/HttpServer/Server.php @@ -104,8 +104,6 @@ class Server extends HttpService */ public function initCore(array $configs): Packet|Websocket|Receive|Http|null { - $this->enableCoroutine((bool)Config::get('settings.enable_coroutine')); - $this->orders($configs); $this->onProcessListener(); return $this->getServer(); @@ -145,6 +143,9 @@ class Server extends HttpService if (!$baseServer) { return 'ok'; } + + $this->enableCoroutine(); + return $baseServer->start(); } @@ -180,9 +181,9 @@ class Server extends HttpService } foreach ($port as $value) { if (Snowflake::isLinux()) { - $output = Coroutine\System::exec('netstat -tunlp | grep ' . $value['port']); + exec('netstat -tunlp | grep ' . $value['port'], $output); } else { - $output = Coroutine\System::exec('lsof -i :' . $value['port'] . ' | grep -i "LISTEN"'); + exec('lsof -i :' . $value['port'] . ' | grep -i "LISTEN"', $output); } if (!empty($output)) { return true; @@ -204,7 +205,6 @@ class Server extends HttpService } - /** * @param bool $isEnable */