From 758c4e7d5b18b5bcf441ccd0faf4235b19c5e304 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Mon, 6 Dec 2021 14:12:03 +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 | 44 ++++++++-------------------- 1 file changed, 13 insertions(+), 31 deletions(-) diff --git a/kiri-engine/FileListen/HotReload.php b/kiri-engine/FileListen/HotReload.php index 25895878..71ed8b18 100644 --- a/kiri-engine/FileListen/HotReload.php +++ b/kiri-engine/FileListen/HotReload.php @@ -50,12 +50,22 @@ class HotReload extends Command /** - * + * @throws ConfigException + * @throws \ReflectionException */ protected function configure() { - $this->setName('sw:wather') - ->setDescription('server start'); + $this->setName('sw:wather')->setDescription('server start'); + $this->dirs = Config::get('inotify', [APP_PATH . 'app']); + swoole_async_set(['enable_coroutine' => false]); + if (!extension_loaded('inotify')) { + $this->driver = Kiri::getDi()->make(Scaner::class, [$this->dirs, $this]); + } else { + $this->driver = Kiri::getDi()->make(Inotify::class, [$this->dirs, $this]); + } + if (Kiri::getPlatform()->isLinux()) { + swoole_set_process_name('[' . Config::get('id', 'sw service.') . '].sw:wather'); + } } @@ -68,18 +78,6 @@ class HotReload extends Command */ public function execute(InputInterface $input, OutputInterface $output): int { - // TODO: Implement onHandler() method. - set_error_handler([$this, 'onErrorHandler']); - $this->dirs = Config::get('inotify', [APP_PATH . 'app']); - swoole_async_set(['enable_coroutine' => false]); - if (!extension_loaded('inotify')) { - $this->driver = Kiri::getDi()->make(Scaner::class, [$this->dirs, $this]); - } else { - $this->driver = Kiri::getDi()->make(Inotify::class, [$this->dirs, $this]); - } - if (Kiri::getPlatform()->isLinux()) { - swoole_set_process_name('[' . Config::get('id', 'sw service.') . '].sw:wather'); - } $this->trigger_reload(); Timer::tick(1000, fn() => $this->healthCheck()); @@ -132,22 +130,6 @@ class HotReload extends Command } - /** - * @param $code - * @param $message - * @param $file - * @param $line - * @throws Exception - */ - public function onErrorHandler($code, $message, $file, $line) - { - if (str_contains($message, 'The file descriptor is not an inotify instance')) { - return; - } - debug('Error:' . $message . ' at ' . $file . ':' . $line); - } - - /** * 重启 *