This commit is contained in:
2021-08-17 18:45:22 +08:00
parent 97c5d94a64
commit a943a6ca25
2 changed files with 4 additions and 3 deletions
+3 -2
View File
@@ -157,7 +157,7 @@ class ServerManager
* @param array $ports * @param array $ports
* @return array * @return array
*/ */
private function sortService(array $ports): array public function sortService(array $ports): array
{ {
$array = []; $array = [];
foreach ($ports as $port) { foreach ($ports as $port) {
@@ -315,7 +315,8 @@ class ServerManager
return; return;
} }
while ($this->checkPortIsAlready($port)) { while ($this->checkPortIsAlready($port)) {
exec('kill ' . $pid, $execResult); exec('kill -15 ' . $pid, $execResult);
Process::kill($pid,);
usleep(300); usleep(300);
} }
} }
+1 -1
View File
@@ -131,7 +131,7 @@ class Server extends HttpService
public function shutdown() public function shutdown()
{ {
$configs = Config::get('server', [], true); $configs = Config::get('server', [], true);
foreach ($configs['ports'] ?? [] as $config) { foreach ($this->manager->sortService($configs) as $config) {
$this->manager->stopServer($config['port']); $this->manager->stopServer($config['port']);
} }
$this->eventDispatch->dispatch(new OnShutdown()); $this->eventDispatch->dispatch(new OnShutdown());