-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstart_chatbot.sh
More file actions
executable file
·103 lines (87 loc) · 2.77 KB
/
start_chatbot.sh
File metadata and controls
executable file
·103 lines (87 loc) · 2.77 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
#!/bin/bash
# Script de inicio rápido para CodeHelperNET
# Este script inicia tanto el backend como el frontend del chatbot
echo "🚀 Iniciando CodeHelperNET Chatbot..."
echo "======================================"
# Verificar si el entorno virtual existe
if [ ! -d "codehelper_env" ]; then
echo "❌ Error: No se encontró el entorno virtual 'codehelper_env'"
echo "Por favor, ejecuta primero:"
echo " python3 -m venv codehelper_env"
echo " source codehelper_env/bin/activate"
echo " pip install -r requirements.txt"
exit 1
fi
# Verificar si el frontend existe
if [ ! -d "frontend" ]; then
echo "❌ Error: No se encontró la carpeta 'frontend'"
echo "Por favor, asegúrate de que el proyecto esté completo"
exit 1
fi
# Función para limpiar procesos al salir
cleanup() {
echo ""
echo "🛑 Deteniendo servidores..."
kill $BACKEND_PID 2>/dev/null
kill $FRONTEND_PID 2>/dev/null
echo "✅ Servidores detenidos"
exit 0
}
# Capturar Ctrl+C para limpiar procesos
trap cleanup SIGINT
echo "📦 Iniciando backend (Python/Flask)..."
echo " Puerto: 5000"
echo " URL: http://localhost:5000"
# Iniciar backend en segundo plano
source codehelper_env/bin/activate
python api_server.py &
BACKEND_PID=$!
# Esperar un momento para que el backend se inicialice
echo "⏳ Esperando que el backend se inicialice..."
sleep 5
# Verificar si el backend está funcionando
if curl -s http://localhost:5000/health > /dev/null; then
echo "✅ Backend iniciado correctamente"
else
echo "❌ Error: No se pudo conectar al backend"
kill $BACKEND_PID 2>/dev/null
exit 1
fi
echo ""
echo "🌐 Iniciando frontend (Next.js)..."
echo " Puerto: 3000"
echo " URL: http://localhost:3000"
# Iniciar frontend en segundo plano
cd frontend
npm run dev &
FRONTEND_PID=$!
cd ..
# Esperar un momento para que el frontend se inicialice
echo "⏳ Esperando que el frontend se inicialice..."
sleep 10
# Verificar si el frontend está funcionando
if curl -s http://localhost:3000 > /dev/null; then
echo "✅ Frontend iniciado correctamente"
else
echo "❌ Error: No se pudo conectar al frontend"
kill $BACKEND_PID 2>/dev/null
kill $FRONTEND_PID 2>/dev/null
exit 1
fi
echo ""
echo "🎉 ¡CodeHelperNET está listo!"
echo "================================"
echo "📱 Frontend: http://localhost:3000"
echo "🔧 Backend: http://localhost:5000"
echo "📊 Health: http://localhost:5000/health"
echo ""
echo "💡 Ejemplos de preguntas:"
echo " • ¿Qué es async/await en C#?"
echo " • ¿Cómo crear una API REST con ASP.NET Core?"
echo " • ¿Qué son los patrones de diseño?"
echo " • ¿Cómo implementar Entity Framework Core?"
echo ""
echo "🛑 Presiona Ctrl+C para detener los servidores"
echo ""
# Mantener el script ejecutándose
wait