-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_servers.py
More file actions
executable file
·51 lines (43 loc) · 1.9 KB
/
run_servers.py
File metadata and controls
executable file
·51 lines (43 loc) · 1.9 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
import subprocess
import os
import platform
def run_servers():
# Get the directory of the current script
base_dir = os.path.dirname(os.path.abspath(__file__))
webapp_dir = os.path.join(base_dir, "ta-scheduling-webapp")
frontend_dir = os.path.join(base_dir, "ta-scheduling-frontend")
system = platform.system()
processes = [] # Make sure to define the processes list
if system == "Darwin": # macOS
print("Detected macOS")
# Set Terminal window titles for macOS
processes.append(subprocess.Popen(
["osascript", "-e", f'tell application "Terminal" to do script "cd {webapp_dir} && echo WebApp Server && run-app"']
))
processes.append(subprocess.Popen(
["osascript", "-e", f'tell application "Terminal" to do script "cd {frontend_dir} && echo Frontend Server && npm run dev"']
))
elif system == "Linux": # Linux
print("Detected Linux")
# Set Terminal window titles for Linux (gnome-terminal)
processes.append(subprocess.Popen(
["bash", "-c", f"cd {webapp_dir} && echo 'WebApp Server' && run-app; exec bash"]
))
processes.append(subprocess.Popen(
["bash", "-c", f"cd {frontend_dir} && echo 'Frontend Server' && npm run dev; exec bash"]
))
elif system == "Windows": # Windows
print("Detected Windows")
# Set Command Prompt titles for Windows
processes.append(subprocess.Popen(
["cmd.exe", "/k", f"cd /d {webapp_dir} && echo WebApp Server && run-app"], shell=True
))
processes.append(subprocess.Popen(
["cmd.exe", "/k", f"cd /d {frontend_dir} && echo Frontend Server && npm run dev"], shell=True
))
else:
print(f"Unsupported OS: {system}")
print(f"Process IDs: {[process.pid for process in processes]}")
if __name__ == "__main__":
# Run the servers
run_servers()