改名
This commit is contained in:
@@ -79,7 +79,7 @@ class ServerManager extends Abstracts\Server
|
|||||||
*/
|
*/
|
||||||
public function addListener(string $type, string $host, int $port, int $mode, array $settings = [])
|
public function addListener(string $type, string $host, int $port, int $mode, array $settings = [])
|
||||||
{
|
{
|
||||||
if ($this->portIsAready($port)) $this->stopServer($port);
|
if ($this->portIsAlready($port)) $this->stopServer($port);
|
||||||
if (!$this->server) {
|
if (!$this->server) {
|
||||||
$this->createBaseServer($type, $host, $port, $mode, $settings);
|
$this->createBaseServer($type, $host, $port, $mode, $settings);
|
||||||
} else {
|
} else {
|
||||||
@@ -300,12 +300,12 @@ class ServerManager extends Abstracts\Server
|
|||||||
*/
|
*/
|
||||||
public function stopServer(int $port)
|
public function stopServer(int $port)
|
||||||
{
|
{
|
||||||
if (!($pid = $this->portIsAready($port))) {
|
if (!($pid = $this->portIsAlready($port))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
exec('kill ' . $pid, $execResult);
|
exec('kill -15 ' . $pid, $execResult);
|
||||||
while ($this->portIsAready($port)) {
|
while ($this->portIsAlready($port)) {
|
||||||
usleep(100);
|
usleep(100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -315,7 +315,7 @@ class ServerManager extends Abstracts\Server
|
|||||||
* @param $port
|
* @param $port
|
||||||
* @return bool|string
|
* @return bool|string
|
||||||
*/
|
*/
|
||||||
private function portIsAready($port): bool|string
|
private function portIsAlready($port): bool|string
|
||||||
{
|
{
|
||||||
exec('netstat -lnp | grep ' . $port . ' | grep "LISTEN" | awk \'{print $7}\'', $output);
|
exec('netstat -lnp | grep ' . $port . ' | grep "LISTEN" | awk \'{print $7}\'', $output);
|
||||||
if (empty($output)) {
|
if (empty($output)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user