-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathstart.sh
More file actions
executable file
·77 lines (63 loc) · 2.05 KB
/
start.sh
File metadata and controls
executable file
·77 lines (63 loc) · 2.05 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
#!/bin/bash
# Web2JSON Agent - Startup Script
# Starts both the backend API and the frontend UI simultaneously
echo "🚀 Starting Web2JSON Agent..."
echo ""
# Check if the port is occupied
if lsof -Pi :8000 -sTCP:LISTEN -t >/dev/null ; then
echo "⚠️ Port 8000 is already in use. Killing existing process..."
lsof -ti:8000 | xargs kill -9 2>/dev/null
sleep 1
fi
if lsof -Pi :5173 -sTCP:LISTEN -t >/dev/null ; then
echo "⚠️ Port 5173 is already in use. Killing existing process..."
lsof -ti:5173 | xargs kill -9 2>/dev/null
sleep 1
fi
# Start the backend
echo "📡 Starting backend API (port 8000)..."
cd /Users/brown/Projects/AILabProject/web2json-agent
# Create logs directory if it doesn't exist
mkdir -p logs
# Production Mode: Disable automatic reloading to avoid restarts triggered by changes in the output directory
# If you need reload for development, use: --reload --reload-exclude 'output/**' --reload-exclude 'logs/**'
uvicorn web2json_api.main:app --host 0.0.0.0 --port 8000 \
--reload-exclude 'output/**' \
--reload-exclude 'logs/**' \
--reload-exclude '*.log' \
> logs/api.log 2>&1 &
BACKEND_PID=$!
echo " Backend PID: $BACKEND_PID"
sleep 3
# Check if the backend has started successfully
if curl -s http://localhost:8000/api/health > /dev/null; then
echo "✅ Backend API started successfully"
else
echo "❌ Failed to start backend API"
exit 1
fi
# Start the frontend
echo ""
echo "🎨 Starting frontend UI (port 5173)..."
cd web2json_ui && npm run dev > ../logs/ui.log 2>&1 &
FRONTEND_PID=$!
echo " Frontend PID: $FRONTEND_PID"
sleep 5
echo ""
echo "✨ Web2JSON Agent is ready!"
echo ""
echo "🌐 Frontend: http://localhost:5173"
echo "📡 Backend API: http://localhost:8000/api/docs"
echo ""
echo "📝 Logs:"
echo " Backend: logs/api.log"
echo " Frontend: logs/ui.log"
echo ""
echo "To stop the services, run: ./stop.sh"
echo "Or press Ctrl+C and run: pkill -f 'uvicorn|vite'"
echo ""
# Save PID
echo $BACKEND_PID > .backend.pid
echo $FRONTEND_PID > .frontend.pid
# Wait for user interruption
wait