File size: 900 Bytes
045edbf |
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 |
#!/bin/bash
# Startup script for Gradio UI
# Default port
PORT=${GRADIO_SERVER_PORT:-7860}
# Check if port is in use
if lsof -Pi :$PORT -sTCP:LISTEN -t >/dev/null 2>&1 ; then
echo "⚠️ Port $PORT is already in use!"
echo ""
echo "Options:"
echo " 1. Use a different port: GRADIO_SERVER_PORT=7861 ./run.sh"
echo " 2. Kill the existing process: kill \$(lsof -t -i:$PORT)"
echo ""
# Try to find an available port
for try_port in {7861..7870}; do
if ! lsof -Pi :$try_port -sTCP:LISTEN -t >/dev/null 2>&1 ; then
echo "✅ Found available port: $try_port"
echo " Starting on port $try_port..."
export GRADIO_SERVER_PORT=$try_port
PORT=$try_port
break
fi
done
fi
echo "🚀 Starting Gradio UI on port $PORT..."
echo " Access at: http://localhost:$PORT"
echo ""
python3 app.py
|