-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathstart.py
More file actions
40 lines (35 loc) · 1.22 KB
/
start.py
File metadata and controls
40 lines (35 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""Startup wrapper that captures and prints errors for debugging."""
import subprocess
import sys
import os
print(f"Python: {sys.version}", flush=True)
print(f"PWD: {os.getcwd()}", flush=True)
print(f"LS: {os.listdir('.')}", flush=True)
print(f"DATABRICKS_HOST: {os.getenv('DATABRICKS_HOST', 'NOT SET')}", flush=True)
print(f"DATABRICKS_TOKEN set: {bool(os.getenv('DATABRICKS_TOKEN'))}", flush=True)
# Install deps
print("=== Installing requirements ===", flush=True)
result = subprocess.run(
[sys.executable, "-m", "pip", "install", "-r", "backend/requirements.txt"],
capture_output=True, text=True
)
print(result.stdout[-500:] if result.stdout else "", flush=True)
if result.returncode != 0:
print(f"PIP FAILED: {result.stderr[-500:]}", flush=True)
sys.exit(1)
print("=== Pip done ===", flush=True)
# Test import
os.chdir("backend")
print(f"Backend PWD: {os.getcwd()}", flush=True)
try:
print("=== Importing app ===", flush=True)
from app.main import app
print("=== Import OK ===", flush=True)
except Exception as e:
print(f"IMPORT FAILED: {e}", flush=True)
import traceback
traceback.print_exc()
sys.exit(1)
# Start uvicorn
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000, log_level="info")