mirror of
https://github.com/cedar2025/Xboard.git
synced 2025-01-22 10:38:14 -05:00
fix: 修复初始化安装时清理缓存报错的问题
修改aapanel 安装文档增加inotify 扩展说明 修改webman.php 自动检测是否安装inotify扩展,如果安装则自动拉取热重载监控
This commit is contained in:
parent
fd52795f49
commit
7246eb6ebc
@ -188,7 +188,7 @@ class XboardInstall extends Command
|
|||||||
$this->saveToEnv($envConfig);
|
$this->saveToEnv($envConfig);
|
||||||
|
|
||||||
$this->call('config:cache');
|
$this->call('config:cache');
|
||||||
$this->call('cache:clear');
|
\Artisan::call('cache:clear');
|
||||||
$this->info('正在导入数据库请稍等...');
|
$this->info('正在导入数据库请稍等...');
|
||||||
\Artisan::call("migrate", ['--force' => true]);
|
\Artisan::call("migrate", ['--force' => true]);
|
||||||
$this->info(\Artisan::output());
|
$this->info(\Artisan::output());
|
||||||
|
@ -23,7 +23,7 @@ URL=https://www.aapanel.com/script/install_6.0_en.sh && if [ -f /usr/bin/curl ];
|
|||||||
- swoole4
|
- swoole4
|
||||||
- readline
|
- readline
|
||||||
- event
|
- event
|
||||||
- inotify
|
- inotify (可选,热重载依赖)
|
||||||
|
|
||||||
4. 解除被禁止函数
|
4. 解除被禁止函数
|
||||||
> aaPanel 面板 > App Store > 找到PHP 8.1点击Setting > Disabled functions 将以下函数从列表中删除
|
> aaPanel 面板 > App Store > 找到PHP 8.1点击Setting > Disabled functions 将以下函数从列表中删除
|
||||||
|
57
webman.php
57
webman.php
@ -23,37 +23,40 @@ $http_worker->onMessage = static function ($connection, $request) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$worker = new Worker();
|
if (extension_loaded('inotify')) {
|
||||||
$worker->name = 'FileMonitor';
|
$worker = new Worker();
|
||||||
$worker->reloadable = false;
|
$worker->name = 'FileMonitor';
|
||||||
$monitor_dirs = ['app', 'bootstrap', 'config', 'resources', 'routes', 'public', '.env'];
|
$worker->reloadable = false;
|
||||||
$monitor_files = array();
|
$monitor_dirs = ['app', 'bootstrap', 'config', 'resources', 'routes', 'public', '.env'];
|
||||||
|
$monitor_files = array();
|
||||||
|
|
||||||
// 进程启动后创建inotify监控句柄
|
// 进程启动后创建inotify监控句柄
|
||||||
$worker->onWorkerStart = function ($worker) {
|
$worker->onWorkerStart = function ($worker) {
|
||||||
if (!extension_loaded('inotify')) {
|
if (!extension_loaded('inotify')) {
|
||||||
echo "FileMonitor : Please install inotify extension.\n";
|
echo "FileMonitor : Please install inotify extension.\n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
global $monitor_dirs, $monitor_files;
|
global $monitor_dirs, $monitor_files;
|
||||||
$worker->inotifyFd = inotify_init();
|
$worker->inotifyFd = inotify_init();
|
||||||
stream_set_blocking($worker->inotifyFd, 0);
|
stream_set_blocking($worker->inotifyFd, 0);
|
||||||
|
|
||||||
foreach ($monitor_dirs as $monitor_dir) {
|
foreach ($monitor_dirs as $monitor_dir) {
|
||||||
$monitor_realpath = realpath(__DIR__ . "/{$monitor_dir}");
|
$monitor_realpath = realpath(__DIR__ . "/{$monitor_dir}");
|
||||||
addInofity($monitor_realpath, $worker->inotifyFd);
|
addInofity($monitor_realpath, $worker->inotifyFd);
|
||||||
if (is_file($monitor_realpath))
|
if (is_file($monitor_realpath))
|
||||||
continue;
|
continue;
|
||||||
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($monitor_realpath, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST);
|
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($monitor_realpath, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST);
|
||||||
foreach ($iterator as $file) {
|
foreach ($iterator as $file) {
|
||||||
if ($file->isDir()) {
|
if ($file->isDir()) {
|
||||||
$realpath = realpath($file);
|
$realpath = realpath($file);
|
||||||
addInofity($realpath, $worker->inotifyFd);
|
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)
|
function addInofity(string $realpath, $fd)
|
||||||
{
|
{
|
||||||
global $monitor_files;
|
global $monitor_files;
|
||||||
|
Loading…
Reference in New Issue
Block a user