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;