bep40 commited on
Commit
a4050b3
·
verified ·
1 Parent(s): e9afd24

Fix: start script that patches in-process before uvicorn

Browse files
Files changed (1) hide show
  1. start_patched.sh +11 -9
start_patched.sh CHANGED
@@ -1,14 +1,16 @@
1
  #!/bin/bash
2
  set -e
3
 
4
- # Apply OpenRouter patch before starting
5
- python -c "
6
- import sys
7
- sys.path.insert(0, '/app')
8
- from patches.openrouter_patch import apply_all_patches
9
- apply_all_patches()
10
- print('[start] Patches applied successfully')
11
- " || echo "[start] Patch apply failed (non-fatal)"
 
 
12
 
13
- # Start the backend (same as original start.sh)
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