Spaces:
Sleeping
Sleeping
Update start.sh
Browse files
start.sh
CHANGED
|
@@ -1,11 +1,41 @@
|
|
| 1 |
#!/bin/bash
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
#!/bin/bash
|
| 2 |
|
| 3 |
+
# Startup script that combines FastAPI and Streamlit on port 7860
|
| 4 |
+
|
| 5 |
+
echo "π Starting HTML to PDF Converter (Combined Mode)..."
|
| 6 |
+
|
| 7 |
+
# Start FastAPI in background on port 7860
|
| 8 |
+
echo "π‘ Starting FastAPI API on port 7860..."
|
| 9 |
+
uvicorn api:app --host 0.0.0.0 --port 7860 &
|
| 10 |
+
API_PID=$!
|
| 11 |
+
|
| 12 |
+
# Give API time to start
|
| 13 |
+
sleep 2
|
| 14 |
+
|
| 15 |
+
# Start Streamlit on port 8501 in background
|
| 16 |
+
echo "π¨ Starting Streamlit UI on port 8501..."
|
| 17 |
+
streamlit run src/streamlit_app.py --server.port=8501 --server.address=0.0.0.0 &
|
| 18 |
+
STREAMLIT_PID=$!
|
| 19 |
+
|
| 20 |
+
echo "β
Services started!"
|
| 21 |
+
echo " - FastAPI API: Port 7860"
|
| 22 |
+
echo " - Streamlit UI: Port 8501"
|
| 23 |
+
echo ""
|
| 24 |
+
echo "π Access:"
|
| 25 |
+
echo " - API Docs: http://localhost:7860/docs"
|
| 26 |
+
echo " - API Health: http://localhost:7860/health"
|
| 27 |
+
echo " - Streamlit: http://localhost:8501"
|
| 28 |
+
|
| 29 |
+
# Function to handle shutdown
|
| 30 |
+
cleanup() {
|
| 31 |
+
echo ""
|
| 32 |
+
echo "π Shutting down services..."
|
| 33 |
+
kill $API_PID $STREAMLIT_PID 2>/dev/null
|
| 34 |
+
exit 0
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
# Trap termination signals
|
| 38 |
+
trap cleanup SIGTERM SIGINT
|
| 39 |
+
|
| 40 |
+
# Wait for both processes
|
| 41 |
+
wait $API_PID $STREAMLIT_PID
|