Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -607,6 +607,20 @@ def main_processing_loop():
|
|
| 607 |
|
| 608 |
# --- FastAPI Endpoints (Unchanged) ---
|
| 609 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 610 |
@app.get("/")
|
| 611 |
async def root():
|
| 612 |
"""Root endpoint to check service status."""
|
|
|
|
| 607 |
|
| 608 |
# --- FastAPI Endpoints (Unchanged) ---
|
| 609 |
|
| 610 |
+
# Add to configuration section
|
| 611 |
+
AUTO_START_PROCESSING = os.environ.get("AUTO_START_PROCESSING", "true").lower() == "true"
|
| 612 |
+
|
| 613 |
+
@app.on_event("startup")
|
| 614 |
+
async def startup_event():
|
| 615 |
+
"""Conditionally start processing based on environment variable."""
|
| 616 |
+
if AUTO_START_PROCESSING:
|
| 617 |
+
log_message("🚀 AUTO_START_PROCESSING enabled - Starting processing loop...", "INFO")
|
| 618 |
+
thread = threading.Thread(target=main_processing_loop, daemon=True)
|
| 619 |
+
thread.start()
|
| 620 |
+
log_message("✅ Background processing thread started", "INFO")
|
| 621 |
+
else:
|
| 622 |
+
log_message("⏸️ AUTO_START_PROCESSING disabled - Use /start endpoint to begin", "INFO")
|
| 623 |
+
|
| 624 |
@app.get("/")
|
| 625 |
async def root():
|
| 626 |
"""Root endpoint to check service status."""
|