File size: 1,391 Bytes
da2430e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/bin/bash
# Start HF Viz with all optimizations enabled

# Start Redis if available
if command -v redis-server &> /dev/null; then
    echo "Starting Redis..."
    redis-server --daemonize yes --port 6379 --maxmemory 512mb --maxmemory-policy allkeys-lru
    sleep 1
    REDIS_ENABLED=true
else
    echo "Redis not available, using in-memory cache"
    REDIS_ENABLED=false
fi

# Start backend
echo "Starting backend with optimizations..."
cd backend
source ../venv/bin/activate

SAMPLE_SIZE=5000 \
REDIS_ENABLED=$REDIS_ENABLED \
REDIS_HOST=localhost \
REDIS_PORT=6379 \
REDIS_TTL=300 \
python -m uvicorn api.main:app --host 0.0.0.0 --port 8000 --reload &

BACKEND_PID=$!
echo "Backend started (PID: $BACKEND_PID)"

# Wait for backend to be ready
echo "Waiting for backend to initialize..."
for i in {1..60}; do
    if curl -s http://localhost:8000/ > /dev/null 2>&1; then
        echo "✓ Backend is ready!"
        break
    fi
    sleep 1
done

# Start frontend
echo "Starting frontend..."
cd ../frontend
npm start &

FRONTEND_PID=$!
echo "Frontend started (PID: $FRONTEND_PID)"

echo ""
echo "🎉 HF Viz is running with all optimizations!"
echo ""
echo "Backend: http://localhost:8000"
echo "Frontend: http://localhost:3000"
echo "API Docs: http://localhost:8000/docs"
echo ""
echo "Press Ctrl+C to stop"

# Wait for user interrupt
trap 'kill $BACKEND_PID $FRONTEND_PID; exit' INT
wait