-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
72 lines (54 loc) · 1.52 KB
/
run.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
from multiprocessing import Process
import sys
from crawl import main as crawl_main
from ping import main as ping_main
from resolve import main as resolve_main
from export import main as export_main
def print_help():
print(
'Usage: run.py [network]\n'
'\t(network = main | regtest)'
)
if len(sys.argv) != 2:
print('Invalid network.\n')
print_help()
exit(1)
network = sys.argv[1]
if network == 'main' or network == 'mainnet':
config_suffix = '.main.conf'
elif network == 'regtest':
config_suffix = '.regtest.conf'
else:
print('Invalid network.\n')
print_help()
exit(1)
def run_crawl():
crawl_config_path = 'conf/crawl' + config_suffix
crawl_main([None, crawl_config_path, 'master'])
def run_ping():
ping_config_path = 'conf/ping' + config_suffix
ping_main([None, ping_config_path, 'master'])
def run_resolve():
resolve_config_path = 'conf/resolve' + config_suffix
resolve_main([None, resolve_config_path, 'master'])
def run_export():
export_config_path = 'conf/export' + config_suffix
export_main([None, export_config_path, 'master'])
try:
crawl = Process(target=run_crawl)
crawl.start()
ping = Process(target=run_ping)
ping.start()
resolve = Process(target=run_resolve)
resolve.start()
export = Process(target=run_export)
export.start()
crawl.join()
ping.join()
resolve.join()
export.join()
except KeyboardInterrupt:
crawl.terminate()
ping.terminate()
resolve.terminate()
export.terminate()