This commit is contained in:
2020-09-11 14:42:03 +08:00
parent 3f782e093b
commit b6381f56c2
+6 -7
View File
@@ -135,21 +135,20 @@ class Server extends Application
/** /**
* @return bool * @return bool
* @throws ConfigException
*/ */
public function isRunner() public function isRunner()
{ {
if (empty($this->port)) { $port = $this->sortServers(Config::get('servers'));
if (empty($port)) {
return false; return false;
} }
if (Snowflake::isLinux()) { if (Snowflake::isLinux()) {
exec('netstat -tunlp | grep ' . $this->port, $output); exec('netstat -tunlp | grep ' . $port[0]['port'], $output);
} else { } else {
exec('lsof -i :' . $this->port . ' | grep -i "LISTEN"', $output); exec('lsof -i :' . $port[0]['port'] . ' | grep -i "LISTEN"', $output);
} }
if (!empty($output)) { return !empty($output);
return true;
}
return false;
} }