18 lines
765 B
Python
18 lines
765 B
Python
import os
|
|
import uvicorn
|
|
from uvicorn.config import LOGGING_CONFIG
|
|
|
|
if __name__ == "__main__":
|
|
# 修改默认日志配置
|
|
LOGGING_CONFIG["formatters"]["default"]["fmt"] = "%(asctime)s - %(levelname)s - %(message)s"
|
|
LOGGING_CONFIG["formatters"]["default"]["datefmt"] = "%Y-%m-%d %H:%M:%S"
|
|
LOGGING_CONFIG["formatters"]["access"][
|
|
"fmt"
|
|
] = '%(asctime)s - %(levelname)s - %(client_addr)s - "%(request_line)s" %(status_code)s'
|
|
LOGGING_CONFIG["formatters"]["access"]["datefmt"] = "%Y-%m-%d %H:%M:%S"
|
|
|
|
host = os.getenv("APP_HOST", "0.0.0.0")
|
|
port = int(os.getenv("APP_PORT", "9999"))
|
|
workers = int(os.getenv("UVICORN_WORKERS", "20"))
|
|
uvicorn.run("app:app", host=host, port=port, workers=workers, log_config=LOGGING_CONFIG)
|