Delete run.py
Browse files
run.py
DELETED
@@ -1,41 +0,0 @@
|
|
1 |
-
import subprocess
|
2 |
-
import sys
|
3 |
-
import time
|
4 |
-
from threading import Thread
|
5 |
-
import os
|
6 |
-
import signal
|
7 |
-
|
8 |
-
def run_fastapi():
|
9 |
-
print("Starting FastAPI server...")
|
10 |
-
subprocess.run([sys.executable, "-m", "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"])
|
11 |
-
|
12 |
-
def run_streamlit():
|
13 |
-
print("Starting Streamlit server...")
|
14 |
-
subprocess.run([sys.executable, "-m", "streamlit", "run", "app.py"])
|
15 |
-
|
16 |
-
def main():
|
17 |
-
# Start FastAPI in a separate thread
|
18 |
-
fastapi_thread = Thread(target=run_fastapi)
|
19 |
-
fastapi_thread.daemon = True
|
20 |
-
fastapi_thread.start()
|
21 |
-
|
22 |
-
# Give FastAPI a moment to start
|
23 |
-
time.sleep(2)
|
24 |
-
|
25 |
-
# Start Streamlit
|
26 |
-
streamlit_thread = Thread(target=run_streamlit)
|
27 |
-
streamlit_thread.daemon = True
|
28 |
-
streamlit_thread.start()
|
29 |
-
|
30 |
-
try:
|
31 |
-
# Keep the main thread alive
|
32 |
-
while True:
|
33 |
-
time.sleep(1)
|
34 |
-
except KeyboardInterrupt:
|
35 |
-
print("\nShutting down servers...")
|
36 |
-
# Send SIGTERM to the current process group
|
37 |
-
os.killpg(os.getpgid(0), signal.SIGTERM)
|
38 |
-
sys.exit(0)
|
39 |
-
|
40 |
-
if __name__ == "__main__":
|
41 |
-
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|