-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnodes_initializer.py
More file actions
35 lines (27 loc) · 865 Bytes
/
nodes_initializer.py
File metadata and controls
35 lines (27 loc) · 865 Bytes
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
import subprocess
import os
def start_all_nodes():
# Start nodes
commands = [
["python", "node1/manage.py", "runserver", "0.0.0.0:8002"],
["python", "node2/manage.py", "runserver", "0.0.0.0:8003"],
]
processes = [subprocess.Popen(cmd) for cmd in commands]
for i, p in enumerate(processes):
print(f"\033[94mStarting node{1}\033[0m")
p.wait()
def start_all_nodes_shell():
commands = [
"python node1/manage.py runserver 0.0.0.0:8002",
"python node2/manage.py runserver 0.0.0.0:8003",
]
for cmd in commands:
subprocess.Popen(["gnome-terminal", "--", "bash", "-c", cmd])
if __name__ == "__main__":
if os.name.lower() == "posix":
try:
start_all_nodes_shell()
except Exception:
start_all_nodes()
else:
start_all_nodes()