diff --git a/Abstracts/BaseProcess.php b/Abstracts/BaseProcess.php index 2121a0f..0b7439d 100644 --- a/Abstracts/BaseProcess.php +++ b/Abstracts/BaseProcess.php @@ -17,16 +17,16 @@ use Swoole\Coroutine; abstract class BaseProcess implements OnProcessInterface { - protected bool $isStop = false; + private bool $stop = false; - protected bool $redirect_stdin_and_stdout = FALSE; + protected bool $redirect_stdin_and_stdout = FALSE; - protected int $pipe_type = SOCK_DGRAM; + protected int $pipe_type = SOCK_DGRAM; - protected bool $enable_coroutine = false; + protected bool $enable_coroutine = false; /** @@ -43,82 +43,82 @@ abstract class BaseProcess implements OnProcessInterface public \Kiri\Di\Container $container; - public string $name = ''; + public string $name = ''; - /** - * @return string - */ - public function getName(): string - { - if (empty($this->name)) { - $this->name = uniqid('p.'); - } - return $this->name; - } + /** + * @return string + */ + public function getName(): string + { + if (empty($this->name)) { + $this->name = uniqid('p.'); + } + return $this->name; + } - /** - * @return bool - */ - public function isStop(): bool - { - return $this->isStop; - } + /** + * @return bool + */ + public function isStop(): bool + { + return $this->stop; + } - /** - * @return bool - */ - public function getRedirectStdinAndStdout(): bool - { - return $this->redirect_stdin_and_stdout; - } + /** + * @return bool + */ + public function getRedirectStdinAndStdout(): bool + { + return $this->redirect_stdin_and_stdout; + } - /** - * @return int - */ - public function getPipeType(): int - { - return $this->pipe_type; - } + /** + * @return int + */ + public function getPipeType(): int + { + return $this->pipe_type; + } - /** - * @return bool - */ - public function isEnableCoroutine(): bool - { - return $this->enable_coroutine; - } + /** + * @return bool + */ + public function isEnableCoroutine(): bool + { + return $this->enable_coroutine; + } - /** - * - */ - public function onProcessStop(): void - { - $this->isStop = true; - } + /** + * + */ + public function stop(): void + { + $this->stop = true; + } - /** - * @return $this - */ - abstract public function onSigterm(): static; + /** + * @return $this + */ + abstract public function onSigterm(): static; /** * @param $data * @return void */ - protected function onShutdown($data): void - { - $this->isStop = true; - $value = Context::get('waite:process:message'); - $this->logger->alert('Process ' . $this->getName() . ' stop'); - if (!is_null($value) && Coroutine::exists((int)$value)) { - Coroutine::cancel((int)$value); - } - } + protected function onShutdown($data): void + { + $this->stop = true; + $value = Context::get('waite:process:message'); + $this->logger->alert('Process ' . $this->getName() . ' stop'); + if (!is_null($value) && Coroutine::exists((int)$value)) { + Coroutine::cancel((int)$value); + } + } }