From 08e4bd5653ff79eeb50ec28bd3522bc2a514ff65 Mon Sep 17 00:00:00 2001 From: jingrow Date: Tue, 4 Nov 2025 14:17:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96dev=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8D=E7=83=AD=E9=87=8D=E8=BD=BD=E7=9B=91?= =?UTF-8?q?=E6=8E=A7=E6=96=87=E4=BB=B6=E6=95=B0=E9=87=8F=E8=BF=87=E5=B0=91?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dev.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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