container->get(ActorManager::class); while (!$this->isStop()) { $read = json_decode($process->read(), true); if (is_null($read) || !isset($read['category'])) { continue; } $message = new ActorMessage($read['userId'], $read['event'], $read['body']); switch ($read['category']) { case ActorState::MESSAGE: $actorManager->write($read['name'], $message); break; case ActorState::CREATE: /** @var ActorInterface $actor */ $actor = $this->container->create($read['class'], $read['constrict'], $read['config']); $actorManager->addActor($actor); break; case ActorState::SHUTDOWN: $actorManager->closeActor($read['name']); break; } } } /** * @return $this */ public function onSigterm(): static { pcntl_signal(SIGTERM, function () { $this->onProcessStop(); }); return $this; } }