From 91de213fb0dcfce4f27c4b78ebc239c8d551cf5c Mon Sep 17 00:00:00 2001 From: "as2252258@163.com" Date: Sun, 11 Apr 2021 19:08:36 +0800 Subject: [PATCH] modify --- System/Process/Process.php | 77 +++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 38 deletions(-) diff --git a/System/Process/Process.php b/System/Process/Process.php index 2d1883f7..9620c4d7 100644 --- a/System/Process/Process.php +++ b/System/Process/Process.php @@ -20,52 +20,53 @@ use Swoole\Coroutine\System; abstract class Process extends \Swoole\Process implements SProcess { - /** @var Application $application */ - protected Application $application; + /** @var Application $application */ + protected Application $application; - /** - * Process constructor. - * @param $application - * @param $name - * @param bool $enable_coroutine - * @throws Exception - */ - public function __construct($application, $name, $enable_coroutine = true) - { - parent::__construct([$this, '_load'], false, 1, $enable_coroutine); - $this->application = $application; - Snowflake::setProcessId($this->pid); + /** + * Process constructor. + * @param $application + * @param $name + * @param bool $enable_coroutine + * @throws Exception + */ + public function __construct($application, $name, $enable_coroutine = true) + { + parent::__construct([$this, '_load'], false, 1, $enable_coroutine); + $this->application = $application; + Snowflake::setProcessId($this->pid); -// $content = System::readFile(storage('runtime.php')); + $content = System::readFile(storage('runtime.php')); -// $annotation = Snowflake::app()->getAnnotation(); -// $annotation->setLoader(unserialize($content)); - } + $annotation = Snowflake::app()->getAnnotation(); + $annotation->setLoader(unserialize($content)); + $annotation->runtime(APP_PATH . 'app/Kafka'); + } - /** - * @param Process $process - * @throws Exception - */ - public function _load(Process $process) - { - putenv('environmental=' . Snowflake::PROCESS); + /** + * @param Process $process + * @throws Exception + */ + public function _load(Process $process) + { + putenv('environmental=' . Snowflake::PROCESS); - fire(Event::SERVER_WORKER_START); - if (Snowflake::getPlatform()->isLinux()) { - name($process->pid, $this->getPrefix()); - } - $this->onHandler($process); - } + fire(Event::SERVER_WORKER_START); + if (Snowflake::getPlatform()->isLinux()) { + name($process->pid, $this->getPrefix()); + } + $this->onHandler($process); + } - /** - * @return string - */ - #[Pure] private function getPrefix(): string - { - return get_called_class(); - } + /** + * @return string + */ + #[Pure] private function getPrefix(): string + { + return get_called_class(); + } }