File size: 1,894 Bytes
8b3bb10 4dc4414 8b3bb10 4dc4414 c358bfb 8b3bb10 4dc4414 8b3bb10 4dc4414 c358bfb 4dc4414 c358bfb 4dc4414 8b3bb10 4dc4414 8b3bb10 |
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 |
#!/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 |