Spaces:
Sleeping
Sleeping
fix: use health-check loop in start.sh and align openenv.yaml port to 7860
Browse filessleep 3 was too short; uvicorn wasn't ready before inference.py connected.
Health-check loop polls /health until server responds (up to 60s).
Also fixes openenv.yaml port from 8000 to 7860 for HF Spaces.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- openenv.yaml +1 -1
- start.sh +21 -2
openenv.yaml
CHANGED
|
@@ -3,7 +3,7 @@ name: debug_env
|
|
| 3 |
type: space
|
| 4 |
runtime: fastapi
|
| 5 |
app: debug_env.server.app:app
|
| 6 |
-
port:
|
| 7 |
description: >
|
| 8 |
A real-world debugging environment where LLM agents fix broken Python code.
|
| 9 |
Tasks range from simple syntax errors to complex logic bugs. Agents use
|
|
|
|
| 3 |
type: space
|
| 4 |
runtime: fastapi
|
| 5 |
app: debug_env.server.app:app
|
| 6 |
+
port: 7860
|
| 7 |
description: >
|
| 8 |
A real-world debugging environment where LLM agents fix broken Python code.
|
| 9 |
Tasks range from simple syntax errors to complex logic bugs. Agents use
|
start.sh
CHANGED
|
@@ -1,6 +1,25 @@
|
|
| 1 |
#!/bin/bash
|
| 2 |
set -e
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
python inference.py
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
#!/bin/bash
|
| 2 |
set -e
|
| 3 |
|
| 4 |
+
echo "Starting OpenEnv server..."
|
| 5 |
+
uvicorn debug_env.server.app:app --host 0.0.0.0 --port 7860 2>&1 &
|
| 6 |
+
UVICORN_PID=$!
|
| 7 |
+
|
| 8 |
+
echo "Waiting for server to be ready..."
|
| 9 |
+
MAX_WAIT=60
|
| 10 |
+
WAITED=0
|
| 11 |
+
until curl -sf http://127.0.0.1:7860/health > /dev/null 2>&1; do
|
| 12 |
+
if [ $WAITED -ge $MAX_WAIT ]; then
|
| 13 |
+
echo "ERROR: Server failed to start within ${MAX_WAIT}s — aborting"
|
| 14 |
+
exit 1
|
| 15 |
+
fi
|
| 16 |
+
sleep 2
|
| 17 |
+
WAITED=$((WAITED + 2))
|
| 18 |
+
echo " waited ${WAITED}s..."
|
| 19 |
+
done
|
| 20 |
+
echo "Server ready after ${WAITED}s"
|
| 21 |
+
|
| 22 |
python inference.py
|
| 23 |
+
|
| 24 |
+
# Keep container alive so HF Space stays in Running state
|
| 25 |
+
wait $UVICORN_PID
|