mirror of
https://github.com/whyour/qinglong.git
synced 2025-11-22 16:38:33 +08:00
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>
This commit is contained in:
parent
eb09a417a1
commit
fbeb4f4a6c
|
|
@ -34,7 +34,8 @@ export_ql_envs
|
||||||
import_config "$@"
|
import_config "$@"
|
||||||
fix_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 服务..."
|
log_with_style "INFO" "⚙️ 2. 启动 pm2 服务..."
|
||||||
reload_pm2
|
reload_pm2
|
||||||
|
|
|
||||||
|
|
@ -272,14 +272,35 @@ random_range() {
|
||||||
|
|
||||||
delete_pm2() {
|
delete_pm2() {
|
||||||
cd $dir_root
|
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() {
|
reload_pm2() {
|
||||||
cd $dir_root
|
cd $dir_root
|
||||||
restore_env_vars
|
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() {
|
diff_time() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user