diff --git a/kiri-server/CoroutineServer.php b/kiri-server/CoroutineServer.php deleted file mode 100644 index 12e1c909..00000000 --- a/kiri-server/CoroutineServer.php +++ /dev/null @@ -1,115 +0,0 @@ -get($customProcess); - } - $this->manager->add(function (Pool $pool, int $workerId) use ($customProcess, $system) { - $process = $pool->getProcess($workerId); - - if (Kiri::getPlatform()->isLinux()) { - $process->name($system . '(' . $customProcess->getName() . ')'); - } - - Kiri::getDi()->get(EventDispatch::class)->dispatch(new OnProcessStart()); - - set_env('environmental', Kiri::PROCESS); - $channel = Coroutine::create(function () use ($process, $customProcess) { - while (!$customProcess->isStop()) { - $message = $process->read(); - if (!empty($message)) { - $message = unserialize($message); - } - if (is_null($message)) { - continue; - } - $customProcess->onBroadcast($message); - } - }); - Context::setContext('waite:process:message', $channel); - - $customProcess->onSigterm()->process($process); - - }, $customProcess->isEnableCoroutine()); - } - - - /** - * @param array $settings - * @return void - */ - public function httpServer(array $settings = []): void - { - $this->manager->add(function (Pool $pool, int $workerId) use ($settings) { - $host = $settings['host']; - $port = $settings['port']; - - $server = new Server($host, $port, false, true); - $server->set($settings); - - $callback = $settings['events'][Constant::REQUEST] ?? null; - if (is_null($callback)) { - $pool->shutdown(); - return; - } - if (is_string($callback[0])) { - $callback[0] = Kiri::getDi()->get($callback[0]); - } - $server->handle('/', $callback); - $server->start(); - }, true); - } - - - /** - * @param array $settings - * @return void - */ - public function websocketServer(array $settings) - { - $this->manager->add(function () use ($settings) { - $host = $settings['host']; - $port = $settings['port']; - - $server = new Server($host, $port, false, true); - $server->set($settings); - $hServer = \Kiri::getDi()->get(\Kiri\Message\Server::class); - $server->handle('/', function (Request $request, Response $response) use ($hServer) { - call_user_func([$hServer, 'onRequest'], $request, $response); - }); - $server->start(); - }, true); - - } - - -} diff --git a/kiri-server/CoroutineTasker.php b/kiri-server/CoroutineTasker.php deleted file mode 100644 index 500101cc..00000000 --- a/kiri-server/CoroutineTasker.php +++ /dev/null @@ -1,54 +0,0 @@ - 1) { - $this->channel = new Channel($taskWorker); - for ($i = 0; $i < $taskWorker; $i++) { - - Coroutine::create(function () { - while ($this->channel->capacity) { - $data = $this->channel->pop(-1); - - $execute = $this->getContainer()->get(OnServerTask::class); - - $task = new Task(); - $task->data = $data; - $execute->onCoroutineTask(null, $task); - } - }); - } - } - } - - - public function dispatch($data) - { - $this->channel->push($data); - } - - -}