-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.py
More file actions
33 lines (24 loc) · 756 Bytes
/
main.py
File metadata and controls
33 lines (24 loc) · 756 Bytes
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
import nb_log
import uvicorn
from core.lib import util
from core.lib.cfg import get_cmd_opts, load_cfg
logger = nb_log.get_logger(__name__)
def uvicorn_run(cfg):
cfg = cfg.get('uvicorn_cfg')
uvicorn.run('app:APP', **cfg)
def main() -> None:
"""
main function, steps are:
1. Get cmd opts with the current environment (dev/prod)
2. Read configs by env (uvicorn.json, logger.json)
3. Run uvicorn application, launch APP in app/__init__.py
for more uvicorn args, refer to uvicorn/config.py
:return: None
"""
opts = get_cmd_opts()
logger.info('launch with cmd opts: %s' % util.pfmt(opts))
cfg = load_cfg(opts['env'])
uvicorn_run(cfg)
# gunicorn_run(cfg)
if __name__ == '__main__':
main()