AIE-RAG / launch.sh
mbudisic's picture
Pulled in main
c358bfb
#!/bin/bash
set -e # Exit immediately if a command exits with a non-zero status
# Function to cleanup processes on exit
cleanup() {
echo "Shutting down services..."
kill $(jobs -p) 2>/dev/null
exit
}
# Set up cleanup on script exit
trap cleanup EXIT
# Display environment info for debugging
echo "=== Environment Information ==="
echo "Python version: $(python --version)"
echo "Current directory: $(pwd)"
echo "Files in directory: $(ls -l)"
echo "==============================="
# Set environment variables for proper WebSocket handling
export UVICORN_WS_PROTOCOL=websockets
# Use default WebSocket path to reduce customization complexity
unset CHAINLIT_SOCKETIO_PATH
unset CHAINLIT_SOCKETIO_ENABLED
export CHAINLIT_LOG_LEVEL=debug
# Disable proxies which can interfere with WebSocket connections
export HTTP_PROXY=""
export HTTPS_PROXY=""
export NO_PROXY="localhost,127.0.0.1"
# Start backend on port 8000
echo "Starting backend on http://0.0.0.0:8000..."
uvicorn backend.main:app --host 0.0.0.0 --port 8000 --log-level debug &
backend_pid=$!
# Wait for backend to start
echo "Waiting for backend to start..."
sleep 5
# Check if backend is running
if ! kill -0 $backend_pid 2>/dev/null; then
echo "ERROR: Backend failed to start!"
exit 1
fi
echo "Backend started successfully with PID $backend_pid"
# Start frontend on port 7860 with specific arguments for WebSocket handling
echo "Starting frontend on http://0.0.0.0:7860..."
chainlit run app.py --host 0.0.0.0 --port 7860 --no-cache &
frontend_pid=$!
# Wait for frontend to start
echo "Waiting for frontend to start..."
sleep 5
# Check if frontend is running
if ! kill -0 $frontend_pid 2>/dev/null; then
echo "ERROR: Frontend failed to start!"
exit 1
fi
echo "Frontend started successfully with PID $frontend_pid"
echo "All services started successfully!"
# Wait for all background processes
wait