From 825539c7920cf6fb88881d1d3e630c2979e9e850 Mon Sep 17 00:00:00 2001 From: Administrator Date: Fri, 5 Nov 2021 00:23:31 +0800 Subject: [PATCH] 111 --- kiri-engine/FileListen/FileChangeCustomProcess.php | 13 ++++++------- kiri-engine/FileListen/Inotify.php | 6 +++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/kiri-engine/FileListen/FileChangeCustomProcess.php b/kiri-engine/FileListen/FileChangeCustomProcess.php index 17a76bef..7be0dc85 100644 --- a/kiri-engine/FileListen/FileChangeCustomProcess.php +++ b/kiri-engine/FileListen/FileChangeCustomProcess.php @@ -56,7 +56,7 @@ class FileChangeCustomProcess extends Command public function execute(InputInterface $input, OutputInterface $output): int { // TODO: Implement onHandler() method. -// set_error_handler([$this, 'onErrorHandler']); + set_error_handler([$this, 'onErrorHandler']); $this->dirs = Config::get('inotify', [APP_PATH . 'app']); if (!extension_loaded('inotify')) { @@ -64,11 +64,10 @@ class FileChangeCustomProcess extends Command } else { $driver = Kiri::getDi()->get(Inotify::class, [$this->dirs, $this]); } - $this->trigger_reload(0); - Coroutine::create(function () use ($driver) { - $driver->start(Coroutine::getCid()); - }); - return 0; + + $driver->start(); + + return 0; } /** @@ -92,7 +91,7 @@ class FileChangeCustomProcess extends Command * * @throws Exception */ - public function trigger_reload($cid) + public function trigger_reload() { Kiri::getDi()->get(Logger::class)->warning('change reload'); diff --git a/kiri-engine/FileListen/Inotify.php b/kiri-engine/FileListen/Inotify.php index 721c7f37..07b3b8f0 100644 --- a/kiri-engine/FileListen/Inotify.php +++ b/kiri-engine/FileListen/Inotify.php @@ -31,15 +31,15 @@ class Inotify /** * @throws Exception */ - public function start($cid) + public function start() { - $this->cid = $cid; $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); } + $this->process->trigger_reload(); Event::add($this->inotify, [$this, 'check']); Event::wait(); } @@ -84,7 +84,7 @@ class Inotify public function reload() { $this->process->isReloading = true; - $this->process->trigger_reload($this->cid); + $this->process->trigger_reload(); $this->clearWatch(); foreach ($this->dirs as $root) {