57 lines
2.0 KiB
PowerShell
57 lines
2.0 KiB
PowerShell
# Windows 本地开发启动脚本
|
||
# 在项目根目录运行:.\scripts\dev-windows.ps1
|
||
|
||
$root = Split-Path -Parent $PSScriptRoot
|
||
Set-Location $root
|
||
|
||
Write-Host "=== 股票行情平台 - Windows 本地开发 ===" -ForegroundColor Cyan
|
||
|
||
# 1. 启动 PostgreSQL + Redis
|
||
Write-Host "`n[1/4] 启动数据库服务 (Docker)..." -ForegroundColor Yellow
|
||
docker-compose -f docker-compose.dev.yml up -d
|
||
if ($LASTEXITCODE -ne 0) {
|
||
Write-Host "错误:Docker 未安装或未启动,请先安装 Docker Desktop" -ForegroundColor Red
|
||
exit 1
|
||
}
|
||
Start-Sleep -Seconds 3
|
||
|
||
# 2. 后端虚拟环境
|
||
Write-Host "`n[2/4] 启动后端 (FastAPI)..." -ForegroundColor Yellow
|
||
Set-Location "$root\backend"
|
||
|
||
if (-not (Test-Path "venv")) {
|
||
Write-Host " 创建虚拟环境..."
|
||
python -m venv venv
|
||
.\venv\Scripts\Activate.ps1
|
||
pip install -r requirements.txt
|
||
} else {
|
||
.\venv\Scripts\Activate.ps1
|
||
}
|
||
|
||
# 后台运行 FastAPI
|
||
Start-Process powershell -ArgumentList "-NoExit", "-Command", `
|
||
"Set-Location '$root\backend'; .\venv\Scripts\Activate.ps1; uvicorn app.main:app --reload --port 8000" `
|
||
-WindowStyle Normal
|
||
|
||
# 3. Celery Worker(Windows 用 --pool=solo)
|
||
Write-Host "`n[3/4] 启动 Celery Worker..." -ForegroundColor Yellow
|
||
Start-Process powershell -ArgumentList "-NoExit", "-Command", `
|
||
"Set-Location '$root\backend'; .\venv\Scripts\Activate.ps1; celery -A celery_app.worker worker -l info --pool=solo" `
|
||
-WindowStyle Normal
|
||
|
||
# 4. 前端
|
||
Write-Host "`n[4/4] 启动前端 (Vite)..." -ForegroundColor Yellow
|
||
Set-Location "$root\frontend"
|
||
if (-not (Test-Path "node_modules")) {
|
||
npm install
|
||
}
|
||
Start-Process powershell -ArgumentList "-NoExit", "-Command", `
|
||
"Set-Location '$root\frontend'; npm run dev" `
|
||
-WindowStyle Normal
|
||
|
||
Write-Host "`n=== 启动完成 ===" -ForegroundColor Green
|
||
Write-Host "前端: http://localhost:5173" -ForegroundColor Cyan
|
||
Write-Host "后端 API: http://localhost:8000/api/docs" -ForegroundColor Cyan
|
||
Write-Host "PostgreSQL: localhost:5432" -ForegroundColor Cyan
|
||
Write-Host "Redis: localhost:6379" -ForegroundColor Cyan
|