-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscrubdash.py
More file actions
executable file
·57 lines (44 loc) · 1.58 KB
/
scrubdash.py
File metadata and controls
executable file
·57 lines (44 loc) · 1.58 KB
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
#!/usr/bin/env python3
"""
This module contains the entry point for the CLI script and the PyPI
console script
"""
import argparse
import yaml
import logging
from multiprocessing import Process, Queue
from scrubdash.asyncio_server.asyncio_server import AsyncioServer
from scrubdash.dash_server.dash_server import start_dash
parser = argparse.ArgumentParser()
parser.add_argument('config_filename')
parser.add_argument('-c', '--continue', dest='cont', action='store_true')
args = parser.parse_args()
CONFIG_FILE = args.config_filename
CONTINUE_RUN = args.cont
logging.basicConfig(level=logging.INFO,
format='[%(levelname)s] %(message)s (%(name)s)')
log = logging.getLogger('main')
with open(CONFIG_FILE) as f:
configs = yaml.load(f, Loader=yaml.SafeLoader)
def main():
asyncio_to_dash_queue = Queue()
asyncio_server = AsyncioServer(configs,
asyncio_to_dash_queue,
CONTINUE_RUN)
# Start the asyncio server in a different process
asyncio = Process(target=asyncio_server.start_server)
asyncio.start()
# Start the dash server in a different process
dash = Process(target=start_dash, args=(configs,
asyncio_to_dash_queue))
dash.start()
try:
asyncio.join()
dash.join()
except KeyboardInterrupt:
# Wait for asyncio server and dash server to shut down
while asyncio.is_alive() or dash.is_alive():
pass
log.info('Successfully shut down scrubdash.')
if __name__ == "__main__":
main()