-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_local.py
More file actions
57 lines (47 loc) · 1.35 KB
/
run_local.py
File metadata and controls
57 lines (47 loc) · 1.35 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import os
import subprocess
import sys
import time
from dotenv import load_dotenv
# Load environment variables from .env file
load_dotenv()
def main():
"""
Starts the RAT server and a client in local development mode.
"""
print("Starting server and client in local development mode...")
# Command to run uvicorn server
server_command = [
sys.executable,
"-m",
"uvicorn",
"server:app",
"--host",
"0.0.0.0",
"--port",
"8000",
"--reload"
]
# Start the server in a background process
server_process = subprocess.Popen(server_command)
# Give the server a moment to start
time.sleep(5)
# Set environment for the client
client_env = os.environ.copy()
client_env["SERVER_URI"] = "ws://127.0.0.1:8000/rat"
# Command to run the client
client_command = [sys.executable, "client.py"]
# Start the client in a background process
#client_process = subprocess.Popen(client_command, env=client_env)
try:
# Wait for the server to exit
server_process.wait()
except KeyboardInterrupt:
print("\nStopping server...")
server_process.terminate()
#client_process.terminate()
server_process.wait()
#lient_process.wait()
print("Server stopped.")
if __name__ == "__main__":
main()