-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.bat
More file actions
75 lines (61 loc) · 2.28 KB
/
Copy pathstart.bat
File metadata and controls
75 lines (61 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
@echo off
chcp 65001 >nul
title 学位申请智能助手
echo.
echo ╔══════════════════════════════════════════╗
echo ║ 研究型学位申请智能助手 ║
echo ║ BMAD - Graduate Application Assistant ║
echo ╚══════════════════════════════════════════╝
echo.
set SCRIPT_DIR=%~dp0
set VENV_PYTHON=%SCRIPT_DIR%backend\.venv\Scripts\python.exe
echo [1/6] 检查 Python 环境...
if not exist "%VENV_PYTHON%" (
echo 创建虚拟环境...
where python >nul 2>&1
if %ERRORLEVEL% neq 0 (
echo [错误] 未找到 Python,请安装 Python 3.11+ https://python.org
pause
exit /b 1
)
python -m venv "%SCRIPT_DIR%backend\.venv"
)
echo [2/6] 安装后端依赖...
"%VENV_PYTHON%" -m pip install -r "%SCRIPT_DIR%backend\requirements.txt" -q
echo [3/6] 执行数据库迁移...
"%VENV_PYTHON%" -c "from alembic.config import Config; from alembic import command; cfg = Config(r'%SCRIPT_DIR%backend\alembic.ini'); command.upgrade(cfg, 'head')" 2>nul
if %ERRORLEVEL% neq 0 (
echo [信息] 数据库迁移完成或无待执行迁移
)
echo [4/6] 检查 Node.js...
where npx >nul 2>&1
if %ERRORLEVEL% neq 0 (
echo [错误] 未找到 npx,请安装 Node.js https://nodejs.org
pause
exit /b 1
)
echo [5/6] 启动后端 API (端口 8400)...
start "BMAD Backend" "%VENV_PYTHON%" -m uvicorn main:app --app-dir "%SCRIPT_DIR%backend" --port 8400 --host 127.0.0.1
echo 等待后端启动...
set RETRIES=0
:health_check
timeout /t 1 /nobreak >nul
set /a RETRIES+=1
curl -s http://localhost:8400/api/health >nul 2>&1
if %ERRORLEVEL% equ 0 goto backend_ready
if %RETRIES% lss 15 goto health_check
echo [警告] 后端启动超时,请检查 backend 窗口的输出
echo 将继续启动前端,但部分功能可能不可用
:backend_ready
echo 后端已就绪 (耗时 %RETRIES% 秒)
echo [6/6] 启动前端界面 (端口 1420)...
echo.
echo 后端 API: http://localhost:8400
echo 前端界面: http://localhost:1420
echo.
echo 正在编译前端,请稍候...
echo.
start "" http://localhost:1420
cd /d "%SCRIPT_DIR%frontend"
call npx vite --port 1420
pause