Spaces:
Sleeping
Sleeping
File size: 616 Bytes
c36de6c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | 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()
|