From 559ae6647ef375a17184263e3b49cdf3009487f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Wed, 11 Nov 2020 15:20:30 +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 | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/System/Process/ServerInotify.php b/System/Process/ServerInotify.php index 11a565d5..d40c956a 100644 --- a/System/Process/ServerInotify.php +++ b/System/Process/ServerInotify.php @@ -92,14 +92,16 @@ class ServerInotify extends Process if (!isset($this->md5Map[$md5])) { if ($isReload) { $this->isReloading = true; - return Timer::after(2000, [$this, 'reload']); + Timer::clearAll(); + return Timer::after(2000, [$this, 'timerReload']); } $this->md5Map[$md5] = $mTime; } else { if ($this->md5Map[$md5] != $mTime) { if ($isReload) { $this->isReloading = true; - return Timer::after(2000, [$this, 'reload']); + Timer::clearAll(); + return Timer::after(2000, [$this, 'timerReload']); } $this->md5Map[$md5] = $mTime; } @@ -165,10 +167,23 @@ class ServerInotify extends Process $this->isReloading = FALSE; $this->isReloadingOut = FALSE; $this->md5Map = []; - if (Snowflake::isMac()) { - $this->loadByDir(APP_PATH . 'app'); - $this->loadByDir(APP_PATH . 'routes'); - } + } + + /** + * @throws Exception + */ + public function timerReload() + { + $this->isReloading = true; + $this->trigger_reload(); + $this->int = -1; + $this->isReloading = FALSE; + $this->isReloadingOut = FALSE; + $this->md5Map = []; + $this->loadByDir(APP_PATH . 'app'); + $this->loadByDir(APP_PATH . 'routes'); + + Timer::tick(2000, [$this, 'tick']); } /**