This commit is contained in:
2021-03-01 15:12:03 +08:00
parent 62e2153446
commit a513de6860
+17 -6
View File
@@ -179,12 +179,17 @@ class Server extends HttpService
if (empty($port)) { if (empty($port)) {
return false; return false;
} }
if (Snowflake::isLinux()) { foreach ($port as $value) {
exec('netstat -tunlp | grep ' . $port[0]['port'], $output); if (Snowflake::isLinux()) {
} else { exec('netstat -tunlp | grep ' . $value['port'], $output);
exec('lsof -i :' . $port[0]['port'] . ' | grep -i "LISTEN"', $output); } else {
exec('lsof -i :' . $value['port'] . ' | grep -i "LISTEN"', $output);
}
if (!empty($output)) {
return true;
}
} }
return !empty($output); return false;
} }
@@ -340,7 +345,13 @@ class Server extends HttpService
} }
private function addListener($config) /**
* @param $config
* @return Http|Packet|Receive|Websocket|null
* @throws NotFindClassException
* @throws ReflectionException
*/
private function addListener($config): Packet|Websocket|Receive|Http|null
{ {
if ($this->isUse($config['port'])) { if ($this->isUse($config['port'])) {
return $this->error_stop($config['host'], $config['port']); return $this->error_stop($config['host'], $config['port']);