This commit is contained in:
2021-03-23 19:03:48 +08:00
parent 48302c5067
commit 4c1dd409b0
3 changed files with 43 additions and 8 deletions
+19
View File
@@ -83,6 +83,25 @@ class Snowflake
}
/**
* @param $port
* @return bool|array
* @throws Exception
*/
public static function port_already($port): bool
{
if (empty($port)) {
return false;
}
if (Snowflake::getPlatform()->isLinux()) {
exec('netstat -tunlp | grep ' . $port, $output);
} else {
exec('lsof -i :' . $port . ' | grep -i "LISTEN"', $output);
}
return !empty($output);
}
/**
* @param $className
* @param array $construct