Spaces:
Paused
Paused
Fix: start script that patches in-process before uvicorn
Browse files- start_patched.sh +11 -9
start_patched.sh
CHANGED
|
@@ -1,14 +1,16 @@
|
|
| 1 |
#!/bin/bash
|
| 2 |
set -e
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
| 12 |
|
| 13 |
-
# Start the backend
|
| 14 |
exec uvicorn main:app --host 0.0.0.0 --port 7860 --workers 1
|
|
|
|
| 1 |
#!/bin/bash
|
| 2 |
set -e
|
| 3 |
|
| 4 |
+
# Inject patch import into backend/main.py at runtime
|
| 5 |
+
# This ensures the patch runs in the same process as the app
|
| 6 |
+
if [ -f /app/patches/openrouter_patch.py ]; then
|
| 7 |
+
# Prepend patch import to backend/main.py
|
| 8 |
+
MAIN_FILE="/app/backend/main.py"
|
| 9 |
+
if ! grep -q "openrouter_patch" "$MAIN_FILE" 2>/dev/null; then
|
| 10 |
+
sed -i '1i\import sys; sys.path.insert(0, "/app"); from patches.openrouter_patch import apply_all_patches; apply_all_patches()' "$MAIN_FILE"
|
| 11 |
+
echo "[start] ✅ OpenRouter patch injected into main.py"
|
| 12 |
+
fi
|
| 13 |
+
fi
|
| 14 |
|
| 15 |
+
# Start the backend
|
| 16 |
exec uvicorn main:app --host 0.0.0.0 --port 7860 --workers 1
|