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\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();
}