This commit is contained in:
2021-03-01 15:12:03 +08:00
parent 62e2153446
commit a513de6860
+15 -4
View File
@@ -179,12 +179,17 @@ class Server extends HttpService
if (empty($port)) { if (empty($port)) {
return false; return false;
} }
foreach ($port as $value) {
if (Snowflake::isLinux()) { if (Snowflake::isLinux()) {
exec('netstat -tunlp | grep ' . $port[0]['port'], $output); exec('netstat -tunlp | grep ' . $value['port'], $output);
} else { } else {
exec('lsof -i :' . $port[0]['port'] . ' | grep -i "LISTEN"', $output); exec('lsof -i :' . $value['port'] . ' | grep -i "LISTEN"', $output);
} }
return !empty($output); if (!empty($output)) {
return true;
}
}
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']);