From c4bca4f88ea455ad79c7163c4a268962a0d9487b Mon Sep 17 00:00:00 2001 From: xl Date: Mon, 18 Nov 2024 14:13:47 +0800 Subject: [PATCH] eee --- Abstracts/HotReload.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Abstracts/HotReload.php b/Abstracts/HotReload.php index 694aa42..c3b0aaa 100644 --- a/Abstracts/HotReload.php +++ b/Abstracts/HotReload.php @@ -5,6 +5,7 @@ namespace Kiri\Server\Abstracts; use Kiri\Di\Inject\Container; use Kiri\Server\ServerInterface; use Psr\Log\LoggerInterface; +use Swoole\Event; use Swoole\Process; use Kiri\Server\Processes\AbstractProcess; @@ -86,12 +87,17 @@ class HotReload extends AbstractProcess public function process(Process|null $process): void { $this->addListen(); - while (!$this->isStop()) { - $read = inotify_read($this->pipe); - if (!empty($read)) { - $this->reload(); + Event::cycle(function (): void { + if ($this->isStop()) { + Event::del($this->pipe); + } else { + $read = inotify_read($this->pipe); + if (!empty($read)) { + $this->reload(); + } } - } + }); + Event::wait(); }