From 7246eb6ebc2ca130cee4a52b38488688240c24c1 Mon Sep 17 00:00:00 2001 From: xboard Date: Wed, 29 May 2024 00:56:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=E5=AE=89=E8=A3=85=E6=97=B6=E6=B8=85=E7=90=86=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9aapanel=20=E5=AE=89=E8=A3=85=E6=96=87?= =?UTF-8?q?=E6=A1=A3=E5=A2=9E=E5=8A=A0inotify=20=E6=89=A9=E5=B1=95?= =?UTF-8?q?=E8=AF=B4=E6=98=8E=20=E4=BF=AE=E6=94=B9webman.php=20=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E6=A3=80=E6=B5=8B=E6=98=AF=E5=90=A6=E5=AE=89=E8=A3=85?= =?UTF-8?q?inotify=E6=89=A9=E5=B1=95=EF=BC=8C=E5=A6=82=E6=9E=9C=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E5=88=99=E8=87=AA=E5=8A=A8=E6=8B=89=E5=8F=96=E7=83=AD?= =?UTF-8?q?=E9=87=8D=E8=BD=BD=E7=9B=91=E6=8E=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Commands/XboardInstall.php | 2 +- docs/aapanel安装指南.md | 2 +- webman.php | 57 ++++++++++++++------------ 3 files changed, 32 insertions(+), 29 deletions(-) diff --git a/app/Console/Commands/XboardInstall.php b/app/Console/Commands/XboardInstall.php index 3cc6d7f..e124736 100644 --- a/app/Console/Commands/XboardInstall.php +++ b/app/Console/Commands/XboardInstall.php @@ -188,7 +188,7 @@ class XboardInstall extends Command $this->saveToEnv($envConfig); $this->call('config:cache'); - $this->call('cache:clear'); + \Artisan::call('cache:clear'); $this->info('正在导入数据库请稍等...'); \Artisan::call("migrate", ['--force' => true]); $this->info(\Artisan::output()); diff --git a/docs/aapanel安装指南.md b/docs/aapanel安装指南.md index 028eb85..6c7bb2b 100644 --- a/docs/aapanel安装指南.md +++ b/docs/aapanel安装指南.md @@ -23,7 +23,7 @@ URL=https://www.aapanel.com/script/install_6.0_en.sh && if [ -f /usr/bin/curl ]; - swoole4 - readline - event -- inotify +- inotify (可选,热重载依赖) 4. 解除被禁止函数 > aaPanel 面板 > App Store > 找到PHP 8.1点击Setting > Disabled functions 将以下函数从列表中删除 diff --git a/webman.php b/webman.php index 0e6cfd4..4c7e28c 100644 --- a/webman.php +++ b/webman.php @@ -23,37 +23,40 @@ $http_worker->onMessage = static function ($connection, $request) { } }; -$worker = new Worker(); -$worker->name = 'FileMonitor'; -$worker->reloadable = false; -$monitor_dirs = ['app', 'bootstrap', 'config', 'resources', 'routes', 'public', '.env']; -$monitor_files = array(); +if (extension_loaded('inotify')) { + $worker = new Worker(); + $worker->name = 'FileMonitor'; + $worker->reloadable = false; + $monitor_dirs = ['app', 'bootstrap', 'config', 'resources', 'routes', 'public', '.env']; + $monitor_files = array(); -// 进程启动后创建inotify监控句柄 -$worker->onWorkerStart = function ($worker) { - if (!extension_loaded('inotify')) { - echo "FileMonitor : Please install inotify extension.\n"; - return; - } - global $monitor_dirs, $monitor_files; - $worker->inotifyFd = inotify_init(); - stream_set_blocking($worker->inotifyFd, 0); + // 进程启动后创建inotify监控句柄 + $worker->onWorkerStart = function ($worker) { + if (!extension_loaded('inotify')) { + echo "FileMonitor : Please install inotify extension.\n"; + return; + } + global $monitor_dirs, $monitor_files; + $worker->inotifyFd = inotify_init(); + stream_set_blocking($worker->inotifyFd, 0); - foreach ($monitor_dirs as $monitor_dir) { - $monitor_realpath = realpath(__DIR__ . "/{$monitor_dir}"); - addInofity($monitor_realpath, $worker->inotifyFd); - if (is_file($monitor_realpath)) - continue; - $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($monitor_realpath, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST); - foreach ($iterator as $file) { - if ($file->isDir()) { - $realpath = realpath($file); - addInofity($realpath, $worker->inotifyFd); + foreach ($monitor_dirs as $monitor_dir) { + $monitor_realpath = realpath(__DIR__ . "/{$monitor_dir}"); + addInofity($monitor_realpath, $worker->inotifyFd); + if (is_file($monitor_realpath)) + continue; + $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($monitor_realpath, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST); + foreach ($iterator as $file) { + if ($file->isDir()) { + $realpath = realpath($file); + addInofity($realpath, $worker->inotifyFd); + } } } - } - Worker::$globalEvent->add($worker->inotifyFd, EventInterface::EV_READ, 'check_files_change'); -}; + Worker::$globalEvent->add($worker->inotifyFd, EventInterface::EV_READ, 'check_files_change'); + }; +} + function addInofity(string $realpath, $fd) { global $monitor_files;