iOSBuildServer/start.sh
shen 6f4f625c56 Initial commit: iOS Build Server
- FastAPI backend with build queue, WebSocket logs, task management
- Vue 3 frontend with build/config/history views
- Xcode project build automation with IPA export
- Fix: initialize build_dir before try block to ensure cleanup on early failure
2026-06-06 17:42:27 +08:00

58 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
# 一键启动本地开发环境(后端 + 前端)
# 用法: ./start.sh
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$SCRIPT_DIR"
# 加载 .env
if [ -f .env ]; then
set -a; source .env; set +a
fi
PORT="${BACKEND_PORT:-8000}"
# 确保 .env 存在
if [ ! -f .env ]; then
echo "首次运行,创建 .env 配置文件..."
cp .env.example .env
fi
# 确保后端依赖
if [ ! -d ".venv" ]; then
echo "创建 Python 虚拟环境..."
python3 -m venv .venv
fi
source .venv/bin/activate
pip install -r requirements.txt -q
# 确保前端依赖
if [ ! -d "frontend/node_modules" ]; then
echo "安装前端依赖..."
cd frontend && npm install --silent && cd ..
fi
echo "=== iOS 自动打包服务(开发模式)==="
echo " 前端: http://localhost:3000"
echo " 后端: http://localhost:$PORT"
echo " 按 Ctrl+C 停止所有服务"
echo ""
# 清理子进程
cleanup() {
kill $BACKEND_PID $FRONTEND_PID 2>/dev/null
wait $BACKEND_PID $FRONTEND_PID 2>/dev/null
}
trap cleanup INT TERM
# 启动后端
python3 -m uvicorn backend.main:app --host 0.0.0.0 --port "$PORT" --reload &
BACKEND_PID=$!
# 启动前端
cd frontend && npm run dev &
FRONTEND_PID=$!
cd "$SCRIPT_DIR"
wait