From a030c078aeae3822be202544581f2c9e7993e047 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Wed, 28 Apr 2021 12:03:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- System/Process/Process.php | 75 ++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 40 deletions(-) diff --git a/System/Process/Process.php b/System/Process/Process.php index 81ff5bbe..698588ae 100644 --- a/System/Process/Process.php +++ b/System/Process/Process.php @@ -18,50 +18,45 @@ abstract class Process extends \Swoole\Process implements SProcess { - /** - * 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); - 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); + Snowflake::setProcessId($this->pid); + } - /** - * @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()); - } - if (method_exists($this, 'before')) { - $this->before($process); - } - if (!Snowflake::getPlatform()->isMac()) { - if (method_exists($this, 'getProcessName')) { - swoole_set_process_name($this->getProcessName()); - } - } - $this->onHandler($process); - } + fire(Event::SERVER_WORKER_START); + if (Snowflake::getPlatform()->isLinux()) { + swoole_set_process_name($this->getProcessName()); + } + if (method_exists($this, 'before')) { + $this->before($process); + } + $this->onHandler($process); + } - /** - * @return string - */ - #[Pure] private function getPrefix(): string - { - return static::class; - } + /** + * @return string + */ + #[Pure] private function getPrefix(): string + { + return static::class; + } }