-
Notifications
You must be signed in to change notification settings - Fork 1
/
launch.py
53 lines (46 loc) · 1.8 KB
/
launch.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
import argparse
import sys
import time
from chainalytic_icon.cli import Console
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument(
'-a', '--aggregator', help='Aggregator endpoint',
)
parser.add_argument(
'-p', '--provider', help='Provider endpoint',
)
parser.add_argument('-i', '--init-config', action='store_true', help='Generate user config')
parser.add_argument('--restart', action='store_true', help='Force restart all running services')
parser.add_argument('--keep-running', action='store_true', help='Prevent console from exiting')
subparsers = parser.add_subparsers(dest='command', help='Sub commands')
stop_parser = subparsers.add_parser('stop', help='Kill running Chainalytic services')
monitor_parser = subparsers.add_parser('m', help='Monitor all or some specific transform')
monitor_parser.add_argument(
'transform_id',
nargs='?',
default=None,
help='Transform ID. Skip to monitor all transforms',
)
monitor_parser.add_argument(
'-r', '--refresh-time', default='1', help='Refresh time of aggregation monitor'
)
args = parser.parse_args()
console = Console(aggregator_endpoint=args.aggregator, provider_endpoint=args.provider)
try:
if args.command == 'stop':
console.stop_services()
elif args.command == 'm':
console.monitor(
args.transform_id, float(args.refresh_time),
)
elif args.init_config:
console.init_config()
else:
console.init_services(force_restart=args.restart)
if args.keep_running:
while 1:
time.sleep(999)
except KeyboardInterrupt:
print('Exited Chainalytic Console')
sys.exit()