modify
This commit is contained in:
@@ -95,8 +95,7 @@ class ServerManager extends Abstracts\Server
|
|||||||
$context = ServerManager::getContext();
|
$context = ServerManager::getContext();
|
||||||
foreach ($this->sortService($configs['ports']) as $config) {
|
foreach ($this->sortService($configs['ports']) as $config) {
|
||||||
if ($this->checkPort($config['port'])) {
|
if ($this->checkPort($config['port'])) {
|
||||||
$this->server->shutdown();
|
$this->stopServer($config['port']);
|
||||||
trigger_error(sprintf('Port %s::%d is already.', $config['host'], $config['port']));
|
|
||||||
}
|
}
|
||||||
$this->startListenerHandler($context, $config);
|
$this->startListenerHandler($context, $config);
|
||||||
}
|
}
|
||||||
@@ -293,6 +292,25 @@ class ServerManager extends Abstracts\Server
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function stopServer(int $port)
|
||||||
|
{
|
||||||
|
exec('netstat -lnp | grep ' . $port . ' | grep "LISTEN" | awk \'{print $7}\'', $output);
|
||||||
|
if (empty($output)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$explode = explode('/', $output);
|
||||||
|
|
||||||
|
exec('kill -15 ' . $explode[0], $execResuklt);
|
||||||
|
while (true) {
|
||||||
|
exec('netstat -lnp | grep ' . $port . ' | grep "LISTEN" | awk \'{print $7}\'', $output);
|
||||||
|
if (empty($output)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @param array $settings
|
* @param array $settings
|
||||||
|
|||||||
Reference in New Issue
Block a user