-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.py
executable file
·34 lines (28 loc) · 927 Bytes
/
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
from _http import start_http
from _scheduler import start_timer, load_scheduler
from _utils import flags, start_temp_updater
from _hap import start_hap
from config import ENABLE_SCHEDULER, ENABLE_HAP, ENABLE_TEMPERATURE_SENSOR, ENABLE_HTTP
import logging
from logging.handlers import TimedRotatingFileHandler
logging.basicConfig(level=logging.INFO, format='[%(levelname)7s][%(asctime)s] %(message)s')
threads = {}
if __name__ == "__main__":
try:
load_scheduler()
if ENABLE_HTTP:
threads['HTTP'] = start_http()
if ENABLE_TEMPERATURE_SENSOR:
threads['TEMP'] = start_temp_updater()
if ENABLE_HAP:
threads['HAP'] = start_hap()
if ENABLE_SCHEDULER:
threads['SCHED'] = start_timer()
for t in threads:
threads[t].start()
for t in threads:
threads[t].join()
except:
for t in threads:
logging.info("Shutting down {}...".format(t))
threads[t].stop_main()