-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.ps1
More file actions
66 lines (57 loc) · 2.7 KB
/
Copy pathstart.ps1
File metadata and controls
66 lines (57 loc) · 2.7 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
# OpenRoute — arranque local de los 3 servicios.
#
# Verifica prerrequisitos, lanza el microservicio FastAPI en una ventana nueva
# y deja Next.js en la ventana actual. Ollama se asume corriendo como servicio
# de Windows (es lo normal tras instalarlo); si no responde, el script aborta.
#
# Uso:
# .\start.ps1
#
# Para parar: cerrar AMBAS ventanas (Ctrl+C en cada una).
$ErrorActionPreference = "Stop"
$root = Split-Path -Parent $MyInvocation.MyCommand.Definition
Set-Location $root
function Test-Service {
param([string]$Name, [string]$Url)
try {
$null = Invoke-WebRequest -Uri $Url -TimeoutSec 3 -UseBasicParsing
Write-Host "[OK] $Name responde en $Url" -ForegroundColor Green
return $true
} catch {
return $false
}
}
Write-Host "`n=== OpenRoute — arranque local ===" -ForegroundColor Cyan
# 1. Ollama (servicio Windows, no lo arrancamos nosotros).
if (-not (Test-Service "Ollama" "http://localhost:11434/api/tags")) {
Write-Host "[ERROR] Ollama no responde en :11434." -ForegroundColor Red
Write-Host " Abre el menú Inicio, busca 'Ollama' y arráncalo, o ejecuta 'ollama serve' en otra ventana." -ForegroundColor Yellow
exit 1
}
# 2. Entorno Python.
if (-not (Test-Path ".venv\Scripts\python.exe")) {
Write-Host "[ERROR] Falta .venv. Créalo con:" -ForegroundColor Red
Write-Host " python -m venv .venv; .\.venv\Scripts\activate; pip install -r requirements.txt" -ForegroundColor Yellow
exit 1
}
Write-Host "[OK] .venv encontrado" -ForegroundColor Green
# 3. node_modules del frontend.
if (-not (Test-Path "web\node_modules")) {
Write-Host "[ERROR] Falta web\node_modules. Ejecuta:" -ForegroundColor Red
Write-Host " cd web; npm install; npx prisma migrate dev; npm run db:seed; cd .." -ForegroundColor Yellow
exit 1
}
Write-Host "[OK] web\node_modules encontrado" -ForegroundColor Green
# 4. SQLite seedeada.
if (-not (Test-Path "web\prisma\dev.db")) {
Write-Host "[WARN] web\prisma\dev.db no existe. Si es la primera vez:" -ForegroundColor Yellow
Write-Host " cd web; npx prisma migrate dev; npm run db:seed; cd .." -ForegroundColor Yellow
}
# 5. FastAPI en ventana nueva. Activa el venv ahí para que uvicorn herede dependencias.
Write-Host "`n[*] Lanzando FastAPI en :8000 (ventana nueva)..." -ForegroundColor Cyan
$apiCommand = "Set-Location '$root'; & '.\.venv\Scripts\python.exe' -m uvicorn app.main:app --reload --port 8000"
Start-Process powershell -ArgumentList "-NoExit", "-Command", $apiCommand
# 6. Next.js en la ventana actual (foreground). Ctrl+C lo para.
Write-Host "[*] Lanzando Next.js en :3000 (esta ventana). Ctrl+C para parar.`n" -ForegroundColor Cyan
Set-Location "$root\web"
npm run dev