From be3db38aae6066cfefd8a424d4d2deeabe1a739e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Mon, 14 Sep 2020 10:38:41 +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/ServerInotify.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/System/Process/ServerInotify.php b/System/Process/ServerInotify.php index 3361da68..f7710851 100644 --- a/System/Process/ServerInotify.php +++ b/System/Process/ServerInotify.php @@ -41,19 +41,20 @@ class ServerInotify extends Process public function onHandler(\Swoole\Process $process) { set_error_handler([$this, 'onErrorHandler']); + $this->dirs = Config::get('inotify', false, [APP_PATH]); if (extension_loaded('inotify')) { $this->inotify = inotify_init(); $this->events = IN_MODIFY | IN_DELETE | IN_CREATE | IN_MOVE; $process->name('event: file change.'); - $this->dirs = Config::get('inotify', false, [APP_PATH]); foreach ($this->dirs as $dir) { $this->watch($dir); } Event::add($this->inotify, [$this, 'check']); Event::wait(); } else { - $this->loadByDir(APP_PATH . 'app'); - $this->loadByDir(APP_PATH . 'routes'); + foreach ($this->dirs as $dir) { + $this->loadByDir($dir); + } Timer::tick(2000, [$this, 'tick']); } } @@ -67,8 +68,9 @@ class ServerInotify extends Process */ public function tick() { - $this->loadByDir(APP_PATH . 'app', true); - $this->loadByDir(APP_PATH . 'routes', true); + foreach ($this->dirs as $dir) { + $this->loadByDir($dir, true); + } }