From b98de033173dee0516a581ab2e4affb1d3f0fa84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Fri, 19 Nov 2021 10:12:53 +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 --- kiri-engine/FileListen/HotReload.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/kiri-engine/FileListen/HotReload.php b/kiri-engine/FileListen/HotReload.php index ea0abb39..e64d12a7 100644 --- a/kiri-engine/FileListen/HotReload.php +++ b/kiri-engine/FileListen/HotReload.php @@ -33,6 +33,9 @@ class HotReload extends Command private ?Process $process = null; + public Inotify|Scaner $driver; + + protected mixed $source = null; protected mixed $pipes = []; @@ -63,9 +66,9 @@ class HotReload extends Command set_error_handler([$this, 'onErrorHandler']); $this->dirs = Config::get('inotify', [APP_PATH . 'app']); if (!extension_loaded('inotify')) { - $driver = Kiri::getDi()->get(Scaner::class, [$this->dirs, $this]); + $this->driver = Kiri::getDi()->get(Scaner::class, [$this->dirs, $this]); } else { - $driver = Kiri::getDi()->get(Inotify::class, [$this->dirs, $this]); + $this->driver = Kiri::getDi()->get(Inotify::class, [$this->dirs, $this]); } if (Kiri::getPlatform()->isLinux()) { swoole_set_process_name('[' . Config::get('id', 'sw service.') . '].sw:wather'); @@ -73,6 +76,7 @@ class HotReload extends Command $this->trigger_reload(); Process::signal(SIGTERM | SIGKILL, function ($data) { var_dump($data); + $this->driver->clear(); $pid = file_get_contents(storage('.swoole.pid')); if (!empty($pid) && Process::kill($pid, 0)) { Process::kill($pid, SIGTERM); @@ -82,7 +86,7 @@ class HotReload extends Command sleep(1); } }); - $driver->start(); + $this->driver->start(); return 0; }