fix: 修复启动脚本不正确的问题

This commit is contained in:
Daniel
2026-03-08 17:37:02 +08:00
parent 06c0e36d92
commit 2dd1117e51
2 changed files with 24 additions and 7 deletions

View File

@@ -8,6 +8,22 @@ cd "$(dirname "$0")/server"
PORT="${PORT:-5599}"
export PORT
# 释放端口,避免 EADDRINUSE上次未退出或多次启动
if command -v lsof >/dev/null 2>&1; then
pids=$(lsof -t -i ":$PORT" 2>/dev/null) || true
if [ -n "$pids" ]; then
echo "[720yun-offline-api] 停止占用端口 ${PORT} 的进程: $pids"
echo "$pids" | xargs kill 2>/dev/null || true
sleep 1
fi
elif command -v fuser >/dev/null 2>&1; then
if fuser -n tcp "$PORT" >/dev/null 2>&1; then
echo "[720yun-offline-api] 停止占用端口 ${PORT} 的进程..."
fuser -k "$PORT/tcp" 2>/dev/null || true
sleep 1
fi
fi
echo "[720yun-offline-api] 安装依赖..."
npm install --no-audit --no-fund