diff --git a/dev.sh b/dev.sh index d71b705..48ac40a 100755 --- a/dev.sh +++ b/dev.sh @@ -170,11 +170,31 @@ build_reload_dirs() { echo "$RELOAD_DIRS" } +# 检查并增加 inotify 限制 +check_inotify_limit() { + local current_limit=$(cat /proc/sys/fs/inotify/max_user_watches 2>/dev/null || echo "0") + local min_limit=524288 + + if [ "$current_limit" -lt "$min_limit" ]; then + warn "inotify 限制较低 ($current_limit),尝试增加到 $min_limit..." + + # 临时增加限制(需要 root 权限) + if sudo sysctl fs.inotify.max_user_watches=$min_limit 2>/dev/null; then + success "inotify 限制已临时增加到 $min_limit" + else + warn "无法自动增加 inotify 限制(需要 root 权限)" + warn "请手动运行: sudo sysctl -w fs.inotify.max_user_watches=524288" + warn "或永久设置: echo 'fs.inotify.max_user_watches=524288' | sudo tee -a /etc/sysctl.conf" + fi + fi +} + # 启动所有服务 start_all() { info "启动开发环境..." ensure_uv cleanup + check_inotify_limit check_redis check_deps