forked from GFW-knocker/gfw_resist_tcp_proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainserver.py
42 lines (32 loc) · 880 Bytes
/
mainserver.py
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
import subprocess
import os
import time
import sys
import signal
scripts = ['vio_server.py', 'quic_server.py']
def run_script(script_name):
if os.name == 'nt':
# Windows
p = subprocess.Popen(['python', script_name])
else:
# linux
os.system(f"pkill -f {script_name}")
time.sleep(0.5)
p = subprocess.Popen(['python3', script_name])
return p
processes = []
def signal_handler(sig, frame):
print('You pressed Ctrl+C!')
for p in processes:
print("terminated:",p)
p.terminate()
sys.exit(0)
if __name__ == "__main__":
p1 = run_script(scripts[0])
time.sleep(1)
p2 = run_script(scripts[1])
processes = [p1,p2]
signal.signal(signal.SIGINT, signal_handler)
p1.wait()
p2.wait()
print("All subprocesses have completed.")