-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstart_middleware.py
More file actions
33 lines (26 loc) · 1.16 KB
/
start_middleware.py
File metadata and controls
33 lines (26 loc) · 1.16 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
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import asyncio
import argparse
from misc import starter
from heart.server import Server
def start():
if args.host:
server = Server(args.host, ssl_cert=(args.cert, args.key))
elif args.port:
server = Server(port=args.port, ssl_cert=(args.cert, args.key))
elif args.host and args.port:
server = Server(args.host, args.port, (args.cert, args.key))
else:
server = Server(ssl_cert=(args.cert, args.key))
asyncio.run(server.start(), debug=False)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Middleware websocket for message exchange between applications')
parser.add_argument('--host', help='Host address')
parser.add_argument('--port', type=int, help='Port')
parser.add_argument('--cert', help='Path to certificate file')
parser.add_argument('--key', help='Path to key file for corresponding certificate')
parser.add_argument('-s', '--signal', choices=['stop'], help='Shut down gracefully')
parser.add_argument('-d', '--debug', action='store_true', help='Debug mode')
args = parser.parse_args()
starter.run('heart', start, parser)