fix: 修复初始化安装时清理缓存报错的问题

修改aapanel 安装文档增加inotify 扩展说明
修改webman.php 自动检测是否安装inotify扩展,如果安装则自动拉取热重载监控
This commit is contained in:
xboard
2024-05-29 00:56:00 +08:00
parent fd52795f49
commit 7246eb6ebc
3 changed files with 32 additions and 29 deletions
+30 -27
View File
@@ -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;