Spaces:
Sleeping
Sleeping
Claude Code commited on
Commit ·
c860f1e
1
Parent(s): e1064e4
Claude Code: Skip worker spawn in minimal mode to ensure uvicorn starts immediately
Browse files
app.py
CHANGED
|
@@ -87,18 +87,24 @@ _worker_process = None
|
|
| 87 |
async def lifespan(app: FastAPI):
|
| 88 |
"""Manage worker process lifecycle."""
|
| 89 |
global _worker_process
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
|
| 103 |
yield # Application runs here
|
| 104 |
|
|
|
|
| 87 |
async def lifespan(app: FastAPI):
|
| 88 |
"""Manage worker process lifecycle."""
|
| 89 |
global _worker_process
|
| 90 |
+
|
| 91 |
+
# CRITICAL: Skip worker spawn in minimal mode to ensure uvicorn starts immediately
|
| 92 |
+
if STARTUP_MODE == "minimal":
|
| 93 |
+
logger.info("[LIFESPAN] MINIMAL MODE: Skipping worker spawn - uvicorn will start immediately")
|
| 94 |
+
_worker_process = None
|
| 95 |
+
else:
|
| 96 |
+
logger.info("[LIFESPAN] Starting up - spawning brain_minimal.py worker process...")
|
| 97 |
+
try:
|
| 98 |
+
# Spawn brain_minimal.py as subprocess
|
| 99 |
+
_worker_process = subprocess.Popen(
|
| 100 |
+
[sys.executable, "/app/brain_minimal.py"],
|
| 101 |
+
stdout=subprocess.PIPE,
|
| 102 |
+
stderr=subprocess.PIPE,
|
| 103 |
+
cwd="/app"
|
| 104 |
+
)
|
| 105 |
+
logger.info(f"[LIFESPAN] Worker process spawned with PID: {_worker_process.pid}")
|
| 106 |
+
except Exception as e:
|
| 107 |
+
logger.error(f"[LIFESPAN] Failed to spawn worker: {e}")
|
| 108 |
|
| 109 |
yield # Application runs here
|
| 110 |
|