This commit is contained in:
2021-12-06 17:58:11 +08:00
parent 94a522588d
commit c19e141f68
2 changed files with 43 additions and 5 deletions
+14 -4
View File
@@ -67,6 +67,9 @@ class ServerManager extends Component
private Server|null $server = null;
protected array $initProcesses = [];
const DEFAULT_EVENT = [
Constant::WORKER_START => [OnServerWorker::class, 'onWorkerStart'],
Constant::WORKER_EXIT => [OnServerWorker::class, 'onWorkerExit'],
@@ -160,14 +163,23 @@ class ServerManager extends Component
if (Kiri::getPlatform()->isLinux()) {
$process->name($system . '(' . $customProcess->getName() . ')');
}
$customProcess->process($process);
$customProcess->onSigterm()->process($process);
}, $customProcess->getRedirectStdinAndStdout(), $customProcess->getPipeType(), $customProcess->isEnableCoroutine());
$this->logger->debug($system . ' ' . $customProcess->getName() . ' start.');
$this->container->setBindings($customProcess->getName(), $process);
$this->initProcesses[$customProcess->getName()] = $process;
$this->server->addProcess($process);
}
/**
* @return array<string,Process>
*/
public function getProcesses(): array
{
return $this->initProcesses;
}
/**
* @return array
*/
@@ -346,7 +358,6 @@ class ServerManager extends Component
* @param array $events
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @throws ReflectionException
*/
private function addTaskListener(array $events = []): void
{
@@ -365,7 +376,6 @@ class ServerManager extends Component
* @param array|null $settings
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @throws ReflectionException
*/
public function bindCallback(?array $settings = [])
{