This commit is contained in:
2021-12-01 16:09:49 +08:00
parent 97a5deda23
commit 955f358577
3 changed files with 84 additions and 39 deletions
+11 -33
View File
@@ -52,10 +52,21 @@ class ServerManager
public int $port = 0;
/**
* @var Logger
*/
#[Inject(Logger::class)]
public Logger $logger;
/**
* @var State
*/
#[Inject(State::class)]
public State $state;
/** @var array<string,Port> */
public array $ports = [];
@@ -149,23 +160,6 @@ class ServerManager
}
/**
* @return bool
* @throws ConfigException
* @throws Exception
*/
public function isRunner(): bool
{
$configs = Config::get('server', [], true);
foreach ($this->sortService($configs['ports']) as $config) {
if (checkPortIsAlready($config['port'])) {
return true;
}
}
return false;
}
/**
* @param string|OnProcessInterface|BaseProcess $customProcess
* @throws Exception
@@ -315,22 +309,6 @@ class ServerManager
}
/**
* @param int $port
* @throws Exception
*/
public function stopServer(int $port)
{
if (!($pid = checkPortIsAlready($port))) {
return;
}
while (checkPortIsAlready($port)) {
Process::kill($pid, SIGTERM);
usleep(300);
}
}
/**
* @param array $settings
* @throws ContainerExceptionInterface