-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathmain.py
More file actions
49 lines (36 loc) · 1.1 KB
/
main.py
File metadata and controls
49 lines (36 loc) · 1.1 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# !/usr/bin/env python
# -*- coding: utf-8 -*-
# =====================================================
# @File :main.py
# @Date :2024/3/19 17:12
# @Author :leemysw
# 2024/3/19 17:12 Create
# =====================================================
import warnings
warnings.filterwarnings("ignore", category=RuntimeWarning)
import uvicorn
from agent.core.config import settings
from agent.utils import utils
from agent.utils.logger import logger
def create_app():
from agent.app import app
return app
app = create_app()
if __name__ == '__main__':
utils.print_info(settings, logger)
if settings.DEBUG:
entrypoint = "main:app"
else:
entrypoint = app
kwargs = {
"app": entrypoint,
"host": settings.HOST,
"port": settings.PORT,
"reload": False if settings.WORKERS != 1 else settings.DEBUG,
"workers": settings.WORKERS,
"lifespan": 'on',
"ws": "websockets-sansio",
"log_config": utils.set_uvicorn_logger(settings.LOGGER_FORMAT),
"reload_excludes": ["playground/"]
}
uvicorn.run(**kwargs)