-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
executable file
·56 lines (45 loc) · 1.43 KB
/
main.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
import logging
import os
import queue
import sys
import threading
import cycler
import webserver
from modules import log
if __name__ == "__main__":
logger = logging.getLogger('waitress')
logger.setLevel(logging.DEBUG)
logger.info("Main Start")
# thread comms event
comsevent = threading.Event()
# message Queues
webqueue = {} # queue.Queue()
cyclerqueue = queue.Queue()
webserver.cyclerqueue = cyclerqueue
webserver.webqueue = webqueue
webserver.comsevent = comsevent
logger.debug("Coms Init")
try:
cycler = cycler.Cycler(name='Cycler', comsevent=comsevent, cyclerqueue=cyclerqueue, webqueue=webqueue)
# Start thread
cycler.daemon = True
cycler.start()
# Start webserver
webserver.run_server()
# serve(webserver.app, host='0.0.0.0', port=8080, threads=6)
print("Web server shutdown")
except KeyboardInterrupt:
logger.debug("Shutdown requested")
comsevent.set()
comsevent.wait()
comsevent.set()
comsevent.wait()
logger.debug("Shutdown completed")
except Exception as e:
comsevent.set()
comsevent.wait()
comsevent.set()
comsevent.wait()
exc_type, exc_obj, exc_tb = sys.exc_info()
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
logger.critical("Exception: '{}' {} {}:{}".format(e, exc_type, fname, exc_tb.tb_lineno))