This commit is contained in:
xl
2024-11-18 14:13:47 +08:00
parent f6a00d89c1
commit c4bca4f88e
+11 -5
View File
@@ -5,6 +5,7 @@ namespace Kiri\Server\Abstracts;
use Kiri\Di\Inject\Container; use Kiri\Di\Inject\Container;
use Kiri\Server\ServerInterface; use Kiri\Server\ServerInterface;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use Swoole\Event;
use Swoole\Process; use Swoole\Process;
use Kiri\Server\Processes\AbstractProcess; use Kiri\Server\Processes\AbstractProcess;
@@ -86,12 +87,17 @@ class HotReload extends AbstractProcess
public function process(Process|null $process): void public function process(Process|null $process): void
{ {
$this->addListen(); $this->addListen();
while (!$this->isStop()) { Event::cycle(function (): void {
$read = inotify_read($this->pipe); if ($this->isStop()) {
if (!empty($read)) { Event::del($this->pipe);
$this->reload(); } else {
$read = inotify_read($this->pipe);
if (!empty($read)) {
$this->reload();
}
} }
} });
Event::wait();
} }