Spaces:
Sleeping
Sleeping
DaCrow13
commited on
Commit
·
edcfb9a
1
Parent(s):
859da78
feat: Introduce `start_space.sh` to orchestrate DVC model pulling and service startup, and update Nginx upstream addresses to 127.0.0.1.
Browse files- nginx.conf +2 -2
- scripts/start_space.sh +16 -4
nginx.conf
CHANGED
|
@@ -22,11 +22,11 @@ http {
|
|
| 22 |
keepalive_timeout 65;
|
| 23 |
|
| 24 |
upstream streamlit {
|
| 25 |
-
server
|
| 26 |
}
|
| 27 |
|
| 28 |
upstream fastapi {
|
| 29 |
-
server
|
| 30 |
}
|
| 31 |
|
| 32 |
server {
|
|
|
|
| 22 |
keepalive_timeout 65;
|
| 23 |
|
| 24 |
upstream streamlit {
|
| 25 |
+
server 127.0.0.1:8501;
|
| 26 |
}
|
| 27 |
|
| 28 |
upstream fastapi {
|
| 29 |
+
server 127.0.0.1:8000;
|
| 30 |
}
|
| 31 |
|
| 32 |
server {
|
scripts/start_space.sh
CHANGED
|
@@ -73,13 +73,25 @@ fi
|
|
| 73 |
echo "$(date) - Final backend check before starting Streamlit..."
|
| 74 |
curl -v http://127.0.0.1:8000/health || echo "FastAPI health check failed!"
|
| 75 |
|
| 76 |
-
echo "$(date) - Starting Streamlit application on
|
| 77 |
-
export API_BASE_URL="http://
|
| 78 |
streamlit run hopcroft_skill_classification_tool_competition/streamlit_app.py \
|
| 79 |
--server.port 8501 \
|
| 80 |
-
--server.address
|
| 81 |
--server.enableCORS=false \
|
| 82 |
-
--server.enableXsrfProtection=false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
|
| 84 |
echo "$(date) - Process started. Tailing Nginx logs for debug..."
|
| 85 |
tail -f /tmp/nginx_startup.log /tmp/fastapi.log
|
|
|
|
| 73 |
echo "$(date) - Final backend check before starting Streamlit..."
|
| 74 |
curl -v http://127.0.0.1:8000/health || echo "FastAPI health check failed!"
|
| 75 |
|
| 76 |
+
echo "$(date) - Starting Streamlit application on 127.0.0.1:8501..."
|
| 77 |
+
export API_BASE_URL="http://127.0.0.1:8000"
|
| 78 |
streamlit run hopcroft_skill_classification_tool_competition/streamlit_app.py \
|
| 79 |
--server.port 8501 \
|
| 80 |
+
--server.address 127.0.0.1 \
|
| 81 |
--server.enableCORS=false \
|
| 82 |
+
--server.enableXsrfProtection=false \
|
| 83 |
+
--server.headless true &
|
| 84 |
+
|
| 85 |
+
# Wait for Streamlit to start
|
| 86 |
+
echo "$(date) - Waiting for Streamlit to start (30s)..."
|
| 87 |
+
for i in {1..30}; do
|
| 88 |
+
if curl -s http://127.0.0.1:8501/healthz > /dev/null; then
|
| 89 |
+
echo "$(date) - Streamlit is UP!"
|
| 90 |
+
break
|
| 91 |
+
fi
|
| 92 |
+
echo "$(date) - Waiting for Streamlit... ($i/30)"
|
| 93 |
+
sleep 2
|
| 94 |
+
done
|
| 95 |
|
| 96 |
echo "$(date) - Process started. Tailing Nginx logs for debug..."
|
| 97 |
tail -f /tmp/nginx_startup.log /tmp/fastapi.log
|