-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
60 lines (40 loc) · 1.23 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
57
58
59
60
#coding: utf-8
import tornado.ioloop
import backend
import frontend
from core.config import Config
def setup_logging(config):
import logging.config
import structlog
logging.config.fileConfig(config.get('LOGGING_CONF'))
structlog.configure(
processors=[
structlog.stdlib.filter_by_level,
structlog.processors.StackInfoRenderer(),
structlog.processors.format_exc_info,
structlog.processors.KeyValueRenderer()
],
context_class=dict,
logger_factory=structlog.stdlib.LoggerFactory(),
wrapper_class=structlog.stdlib.BoundLogger,
cache_logger_on_first_use=True
)
def setup_database(path):
from core.sqlstore import store
store.configure(path=path)
def setup_items(path):
from core import items
items.configure(path)
def run():
config = Config()
config.from_object('configs.default')
setup_logging(config)
setup_database(config.get('DB_PATH'))
setup_items(config.get('ITEMS_CONF'))
backend_app = backend.build(**config)
backend_app.run()
frontend_app = frontend.build(**config)
frontend_app.run()
tornado.ioloop.IOLoop.instance().start()
if __name__ == '__main__':
run()