import subprocess import sys import os print("--- CUSTOM RUNNER STARTING ---", flush=True) port = os.getenv("PORT", "7860") print(f"Starting uvicorn on port {port}...", flush=True) # Run Uvicorn as a subprocess and stream its output directly to our stdout process = subprocess.Popen( [sys.executable, "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", str(port), "--log-level", "info"], stdout=sys.stdout, stderr=sys.stderr, env=os.environ.copy() ) try: process.wait() except KeyboardInterrupt: print("Shutting down...", flush=True) process.terminate()