From e864df5129cc600590e723a03cc000ca4af1e49d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Tue, 20 Jul 2021 11:35:17 +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/Biomonitoring.php | 13 +++---------- System/Process/ServerInotify.php | 25 ++++++++----------------- 2 files changed, 11 insertions(+), 27 deletions(-) diff --git a/System/Process/Biomonitoring.php b/System/Process/Biomonitoring.php index 9568db65..0c23c14d 100644 --- a/System/Process/Biomonitoring.php +++ b/System/Process/Biomonitoring.php @@ -6,6 +6,7 @@ namespace Snowflake\Process; use Exception; use JetBrains\PhpStorm\Pure; +use Server\SInterface\CustomProcess; use Snowflake\Snowflake; use Swoole\Timer; @@ -13,23 +14,15 @@ use Swoole\Timer; * Class Biomonitoring * @package components */ -class Biomonitoring extends Process +class Biomonitoring implements CustomProcess { /** * @param \Swoole\Process $process - */ - public function before(\Swoole\Process $process): void - { - // TODO: Implement before() method. - } - - - /** * @return string */ - #[Pure] public function getProcessName(): string + #[Pure] public function getProcessName(\Swoole\Process $process): string { // TODO: Implement getProcessName() method. return get_called_class(); diff --git a/System/Process/ServerInotify.php b/System/Process/ServerInotify.php index fb82a00b..317b9afa 100644 --- a/System/Process/ServerInotify.php +++ b/System/Process/ServerInotify.php @@ -11,6 +11,7 @@ namespace Snowflake\Process; use Exception; +use Server\SInterface\CustomProcess; use Snowflake\Abstracts\Config; use Snowflake\Exception\ConfigException; use Snowflake\Snowflake; @@ -21,7 +22,7 @@ use Swoole\Timer; * Class ServerInotify * @package Snowflake\Snowflake\Server */ -class ServerInotify extends Process +class ServerInotify implements CustomProcess { private mixed $inotify; private bool $isReloading = false; @@ -35,24 +36,9 @@ class ServerInotify extends Process /** * @param \Swoole\Process $process - * @throws ConfigException - */ - public function before(\Swoole\Process $process): void - { - // TODO: Implement before() method. - set_error_handler([$this, 'onErrorHandler']); - $this->dirs = Config::get('inotify', [APP_PATH]); - if (extension_loaded('inotify')) { - $this->inotify = inotify_init(); - $this->events = IN_MODIFY | IN_DELETE | IN_CREATE | IN_MOVE; - } - } - - - /** * @return string */ - public function getProcessName(): string + public function getProcessName(\Swoole\Process $process): string { return 'file change process'; } @@ -64,7 +50,12 @@ class ServerInotify extends Process */ public function onHandler(\Swoole\Process $process): void { + // TODO: Implement before() method. + set_error_handler([$this, 'onErrorHandler']); + $this->dirs = Config::get('inotify', [APP_PATH]); if (extension_loaded('inotify')) { + $this->inotify = inotify_init(); + $this->events = IN_MODIFY | IN_DELETE | IN_CREATE | IN_MOVE; foreach ($this->dirs as $dir) { if (!is_dir($dir)) continue; $this->watch($dir);