From 77aa761e8261fbbdd9776ec2093729f747631f80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Fri, 5 Nov 2021 11:01:42 +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/FileChangeCustomProcess.php | 7 ++++--- kiri-engine/FileListen/Inotify.php | 6 ++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/kiri-engine/FileListen/FileChangeCustomProcess.php b/kiri-engine/FileListen/FileChangeCustomProcess.php index 07c2bfd1..18010fb5 100644 --- a/kiri-engine/FileListen/FileChangeCustomProcess.php +++ b/kiri-engine/FileListen/FileChangeCustomProcess.php @@ -66,10 +66,10 @@ class FileChangeCustomProcess extends Command $this->trigger_reload(); Coroutine::create(function () use ($driver) { - Coroutine::create(function () { + Coroutine::create(function () use ($driver) { $waite = Coroutine::waitSignal(SIGTERM | SIGKILL); if ($waite) { - $this->stop(); + $this->stop($driver); } }); $driver->start(); @@ -81,8 +81,9 @@ class FileChangeCustomProcess extends Command /** * @throws Exception */ - private function stop(): void + private function stop($driver): void { + $driver->clear(); if (!file_exists(storage('.swoole.pid'))) { return; } diff --git a/kiri-engine/FileListen/Inotify.php b/kiri-engine/FileListen/Inotify.php index d6abc4b3..cd10f307 100644 --- a/kiri-engine/FileListen/Inotify.php +++ b/kiri-engine/FileListen/Inotify.php @@ -44,6 +44,12 @@ class Inotify } + public function clear() + { + Event::del($this->inotify); + } + + /** * 开始监听 */