DinoPLayZ commited on
Commit
c36de6c
·
verified ·
1 Parent(s): 932ee5d

Upload run.py

Browse files
Files changed (1) hide show
  1. run.py +22 -0
run.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import subprocess
2
+ import sys
3
+ import os
4
+
5
+ print("--- CUSTOM RUNNER STARTING ---", flush=True)
6
+
7
+ port = os.getenv("PORT", "7860")
8
+ print(f"Starting uvicorn on port {port}...", flush=True)
9
+
10
+ # Run Uvicorn as a subprocess and stream its output directly to our stdout
11
+ process = subprocess.Popen(
12
+ [sys.executable, "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", str(port), "--log-level", "info"],
13
+ stdout=sys.stdout,
14
+ stderr=sys.stderr,
15
+ env=os.environ.copy()
16
+ )
17
+
18
+ try:
19
+ process.wait()
20
+ except KeyboardInterrupt:
21
+ print("Shutting down...", flush=True)
22
+ process.terminate()