fix: 修复启动脚本不正确的问题
This commit is contained in:
16
start-api.sh
16
start-api.sh
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user