-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.ps1
More file actions
125 lines (110 loc) · 5.83 KB
/
start.ps1
File metadata and controls
125 lines (110 loc) · 5.83 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# =====================================================
# TaskPro - Script de Inicio Rápido (Windows PowerShell)
# =====================================================
# Este script facilita el inicio y gestión del proyecto TaskPro
Write-Host "`n========================================" -ForegroundColor Cyan
Write-Host " TaskPro - Inicio Rápido" -ForegroundColor Cyan
Write-Host "========================================`n" -ForegroundColor Cyan
# Función para mostrar el menú
function Show-Menu {
Write-Host "Selecciona una opción:" -ForegroundColor Yellow
Write-Host ""
Write-Host "1. 🚀 Iniciar todos los servicios (Docker)" -ForegroundColor Green
Write-Host "2. 🛑 Detener todos los servicios" -ForegroundColor Red
Write-Host "3. 📊 Ver logs del backend" -ForegroundColor Blue
Write-Host "4. 🔍 Ver estado de los contenedores" -ForegroundColor Magenta
Write-Host "5. 🗄️ Cargar datos de ejemplo en BD" -ForegroundColor Cyan
Write-Host "6. 🧪 Probar endpoint de análisis" -ForegroundColor Yellow
Write-Host "7. 📚 Ver documentación interactiva (Swagger)" -ForegroundColor White
Write-Host "8. 🧹 Limpiar volúmenes y rebuild" -ForegroundColor DarkYellow
Write-Host "9. ❌ Salir" -ForegroundColor Gray
Write-Host ""
}
# Bucle principal
do {
Show-Menu
$option = Read-Host "Ingresa el número de opción"
switch ($option) {
'1' {
Write-Host "`n🚀 Iniciando servicios con Docker Compose..." -ForegroundColor Green
docker-compose -f docker-compose.local.yml up --build -d
Write-Host "`n✅ Servicios iniciados correctamente!" -ForegroundColor Green
Write-Host " - Backend API: http://localhost:8000" -ForegroundColor White
Write-Host " - Swagger Docs: http://localhost:8000/docs" -ForegroundColor White
Write-Host " - PostgreSQL: localhost:5432" -ForegroundColor White
Start-Sleep -Seconds 2
}
'2' {
Write-Host "`n🛑 Deteniendo servicios..." -ForegroundColor Red
docker-compose -f docker-compose.local.yml down
Write-Host "✅ Servicios detenidos" -ForegroundColor Green
Start-Sleep -Seconds 2
}
'3' {
Write-Host "`n📊 Mostrando logs del backend (Ctrl+C para salir)..." -ForegroundColor Blue
docker-compose -f docker-compose.local.yml logs -f backend
}
'4' {
Write-Host "`n🔍 Estado de los contenedores:" -ForegroundColor Magenta
docker-compose -f docker-compose.local.yml ps
Start-Sleep -Seconds 3
}
'5' {
Write-Host "`n🗄️ Cargando datos de ejemplo..." -ForegroundColor Cyan
Write-Host "Ejecutando script SQL en PostgreSQL..." -ForegroundColor White
# Ejecutar el script SQL dentro del contenedor de PostgreSQL
docker exec -i gaply-postgres-1 psql -U taskpro_user -d taskpro_db < backend/datos_ejemplo.sql
Write-Host "✅ Datos cargados correctamente!" -ForegroundColor Green
Start-Sleep -Seconds 2
}
'6' {
Write-Host "`n🧪 Probando endpoint de análisis..." -ForegroundColor Yellow
Write-Host "Enviando solicitud de prueba..." -ForegroundColor White
$body = @{
texto_usuario = "Necesito un plomero urgente, se me rompió un caño en la cocina y está saliendo agua"
} | ConvertTo-Json
try {
$response = Invoke-RestMethod -Uri "http://localhost:8000/solicitudes/analizar" `
-Method Post `
-ContentType "application/json" `
-Body $body
Write-Host "`n✅ Respuesta del Agente Analista:" -ForegroundColor Green
Write-Host "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -ForegroundColor Gray
$response | ConvertTo-Json -Depth 5 | Write-Host -ForegroundColor Cyan
Write-Host "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -ForegroundColor Gray
} catch {
Write-Host "❌ Error al conectar con el backend. ¿Está corriendo?" -ForegroundColor Red
Write-Host $_.Exception.Message -ForegroundColor DarkRed
}
Start-Sleep -Seconds 3
}
'7' {
Write-Host "`n📚 Abriendo documentación interactiva en el navegador..." -ForegroundColor White
Start-Process "http://localhost:8000/docs"
Start-Sleep -Seconds 2
}
'8' {
Write-Host "`n🧹 Limpiando volúmenes y reconstruyendo..." -ForegroundColor DarkYellow
Write-Host "⚠️ ADVERTENCIA: Esto eliminará todos los datos de la base de datos." -ForegroundColor Red
$confirm = Read-Host "¿Estás seguro? (s/n)"
if ($confirm -eq 's' -or $confirm -eq 'S') {
docker-compose -f docker-compose.local.yml down -v
docker-compose -f docker-compose.local.yml up --build -d
Write-Host "✅ Rebuild completo exitoso!" -ForegroundColor Green
} else {
Write-Host "❌ Operación cancelada" -ForegroundColor Yellow
}
Start-Sleep -Seconds 2
}
'9' {
Write-Host "`n👋 ¡Hasta pronto!" -ForegroundColor Cyan
break
}
default {
Write-Host "`n❌ Opción inválida. Intenta nuevamente." -ForegroundColor Red
Start-Sleep -Seconds 1
}
}
Write-Host "`n"
} while ($option -ne '9')
Write-Host "========================================`n" -ForegroundColor Cyan