Files
promote/backend/start-server.sh
2025-03-07 18:04:27 +08:00

26 lines
592 B
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# 获取配置的端口默认为4000
PORT=$(grep "PORT=" .env | cut -d= -f2 || echo "4000")
echo "Service configured to use port $PORT"
# 查找并停止使用该端口的进程
PID=$(lsof -ti :$PORT)
if [ ! -z "$PID" ]; then
echo "Stopping process $PID using port $PORT..."
kill -9 $PID
sleep 1
fi
# 停止可能正在运行的服务器
echo "Stopping any running server..."
pkill -f "node dist/index.js" || true
pkill -f "tsx watch src/index.ts" || true
# 构建项目
echo "Building project..."
npm run build
# 启动服务器
echo "Starting server..."
npm start