File size: 709 Bytes
b4ac377
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash
# Start FastAPI on 7860, Gradio on 7861
# HF Space exposes 7860 — Gradio proxies to FastAPI internally

# Start FastAPI in background
uvicorn app.main:app --host 0.0.0.0 --port 7860 --workers 1 &
FASTAPI_PID=$!

# Wait for FastAPI to be ready
echo "Waiting for FastAPI..."
until curl -sf http://localhost:7860/health > /dev/null 2>&1; do
  sleep 1
done
echo "FastAPI ready."

# Start Gradio on 7860 (replaces FastAPI as the public face)
# Gradio calls FastAPI internally at localhost:7860
# We need to run Gradio on a different port and use a reverse proxy
# Simplest: run Gradio as the main process on 7860, FastAPI on 7861

echo "All services started."
wait $FASTAPI_PID