Files
gitlab-instance-0a899031_cn…/scripts/dev-windows.ps1
2026-06-07 23:57:52 -05:00

43 lines
1.4 KiB
PowerShell
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.
# Windows 本地开发:隧道 + FastAPI + Next.js
# 用法powershell -ExecutionPolicy Bypass -File scripts/dev-windows.ps1
$ErrorActionPreference = "Stop"
$Root = Split-Path -Parent $PSScriptRoot
Set-Location $Root
Write-Host "==> NomadCNA Windows 本地开发(连线上 nomadro.cn 服务)" -ForegroundColor Cyan
Write-Host " 1. SSH 隧道 MinIO 127.0.0.1:9100"
Write-Host " 2. FastAPI http://127.0.0.1:8000"
Write-Host " 3. Next.js http://localhost:3001"
Write-Host ""
if (-not (Test-Path "backend\.venv")) {
Write-Host "创建 Python 虚拟环境..." -ForegroundColor Yellow
python -m venv backend\.venv
& backend\.venv\Scripts\pip install -r backend\requirements.txt
}
Write-Host "启动 SSH 隧道(后台)..." -ForegroundColor Green
$tunnelJob = Start-Job -ScriptBlock {
Set-Location $using:Root
python scripts/dev-tunnel.py
}
Start-Sleep -Seconds 2
Write-Host "启动 FastAPI后台..." -ForegroundColor Green
$apiJob = Start-Job -ScriptBlock {
Set-Location $using:Root
& backend\.venv\Scripts\uvicorn backend.main:app --host 127.0.0.1 --port 8000 --reload
}
Start-Sleep -Seconds 2
Write-Host "启动 Next.js前台..." -ForegroundColor Green
try {
pnpm dev
}
finally {
Write-Host "停止后台服务..." -ForegroundColor Yellow
Stop-Job $tunnelJob, $apiJob -ErrorAction SilentlyContinue
Remove-Job $tunnelJob, $apiJob -Force -ErrorAction SilentlyContinue
}