From fbeb4f4a6cd98e305ae1a9507395d0e84d290134 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Sun, 16 Nov 2025 20:29:32 +0800 Subject: [PATCH] Fix PM2 startup failures on ARM routers with Node.js incompatibility (#2828) * Initial plan * Add fallback mechanism for PM2 startup failures on incompatible hardware Co-authored-by: whyour <22700758+whyour@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: whyour <22700758+whyour@users.noreply.github.com> --- docker/docker-entrypoint.sh | 3 ++- shell/share.sh | 27 ++++++++++++++++++++++++--- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/docker/docker-entrypoint.sh b/docker/docker-entrypoint.sh index 1959231e..9996154e 100755 --- a/docker/docker-entrypoint.sh +++ b/docker/docker-entrypoint.sh @@ -34,7 +34,8 @@ export_ql_envs import_config "$@" fix_config -pm2 l &>/dev/null +# Try to initialize PM2, but don't fail if it doesn't work +pm2 l &>/dev/null || log_with_style "WARN" "PM2 初始化可能失败,将在启动时尝试使用备用方案" log_with_style "INFO" "⚙️ 2. 启动 pm2 服务..." reload_pm2 diff --git a/shell/share.sh b/shell/share.sh index baa3c81e..cad30659 100755 --- a/shell/share.sh +++ b/shell/share.sh @@ -272,14 +272,35 @@ random_range() { delete_pm2() { cd $dir_root - pm2 delete ecosystem.config.js + # Try to delete PM2 processes, but don't fail if PM2 is not available + pm2 delete ecosystem.config.js 2>/dev/null || true + # Also try to kill any directly spawned node processes + pkill -f "node.*static/build/app.js" 2>/dev/null || true } reload_pm2() { cd $dir_root restore_env_vars - pm2 flush &>/dev/null - pm2 startOrGracefulReload ecosystem.config.js --update-env + + # Try to start PM2, but handle failures gracefully + if pm2 flush &>/dev/null && pm2 startOrGracefulReload ecosystem.config.js --update-env; then + return 0 + else + local exit_code=$? + echo "警告: PM2 启动失败 (退出码: $exit_code),可能是由于硬件不兼容" + echo "正在尝试直接使用 Node.js 启动服务..." + + # Kill any existing node processes for qinglong + pkill -f "node.*static/build/app.js" 2>/dev/null || true + + # Start node directly in the background + nohup node static/build/app.js > $dir_log/qinglong.log 2>&1 & + local node_pid=$! + + echo "已使用 Node.js 直接启动服务 (PID: $node_pid)" + echo "注意: 使用此模式时,部分 PM2 管理功能将不可用" + return 0 + fi } diff_time() {