-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·46 lines (37 loc) · 1.06 KB
/
Copy pathrun.sh
File metadata and controls
executable file
·46 lines (37 loc) · 1.06 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
#!/bin/bash
set -e
# Cleanup on exit (Ctrl+C, terminal close, etc.)
cleanup() {
echo "Shutting down..."
kill $BACKEND_PID 2>/dev/null
wait $BACKEND_PID 2>/dev/null
}
trap cleanup EXIT INT TERM
# Start Ollama if not already running
if ! pgrep -x "ollama" > /dev/null; then
echo "Starting Ollama..."
ollama serve &
sleep 3
fi
# Pull model if not already present
echo "Pulling model (llama3.2:latest)..."
ollama pull llama3.2:latest
# Start backend
echo "Starting FastAPI backend on port 8000..."
uvicorn backend.main:app --host 0.0.0.0 --port 8000 &
BACKEND_PID=$!
echo "Waiting for backend to be ready..."
MAX_WAIT=120
WAITED=0
until curl -sf http://localhost:8000/health > /dev/null 2>&1; do
if [ $WAITED -ge $MAX_WAIT ]; then
echo "ERROR: Backend failed to start within ${MAX_WAIT}s"
exit 1
fi
sleep 1
WAITED=$((WAITED + 1))
done
echo "Backend is ready (took ~${WAITED}s)"
# Start frontend (blocks until user exits)
echo "Starting Streamlit frontend on port 8501..."
streamlit run frontend/app.py --server.port 8501