-
Notifications
You must be signed in to change notification settings - Fork 0
/
coordinator_start.py
executable file
·41 lines (35 loc) · 1.47 KB
/
coordinator_start.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
#!/usr/bin/env python
from optparse import OptionParser
import signal
import sys
import logging
from meerkat_backend_interface.coordinator import Coordinator
from meerkat_backend_interface.logger import log, set_logger
def cli(prog = sys.argv[0]):
"""Command line interface.
"""
usage = "usage: %prog [options]"
parser = OptionParser(usage=usage)
parser.add_option('-e', '--endpoint', dest='port', type=str,
help='Redis endpoint to connect to (host:port)', default='127.0.0.1:6379')
parser.add_option('-c', '--config', dest='cfg_file', type=str,
help='Config filename (yaml)', default = 'config.yml')
parser.add_option('-t', '--trigger_mode', dest='trigger_mode', type=str,
help="""Trigger mode:
\'nshot:<n>\': PKTSTART will be sent
for <n> tracked targets.
""",
default = 'nshot:0')
(opts, args) = parser.parse_args()
main(port=opts.port, cfg_file=opts.cfg_file, trigger_mode=opts.trigger_mode)
def on_shutdown():
log.info("Coordinator shutting down.")
sys.exit()
def main(port, cfg_file, trigger_mode):
log = set_logger(log_level = logging.DEBUG)
log.info("Starting Coordinator")
coord = Coordinator(port, cfg_file, trigger_mode)
signal.signal(signal.SIGINT, lambda sig, frame: on_shutdown())
coord.start()
if(__name__ == '__main__'):
cli()