You've already forked favicon-api-v3
25.09.03
This commit is contained in:
49
conf.default/gunicorn.conf.py
Normal file
49
conf.default/gunicorn.conf.py
Normal file
@@ -0,0 +1,49 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
import yaml
|
||||
|
||||
# 绑定地址和端口
|
||||
bind = "0.0.0.0:8000"
|
||||
|
||||
# Worker 进程数(推荐 CPU 核心数 * 2 + 1)
|
||||
workers = 4
|
||||
|
||||
# 工作模式(sync、gevent、uvicorn.workers.UvicornWorker)
|
||||
worker_class = "uvicorn.workers.UvicornWorker"
|
||||
|
||||
# 日志目录
|
||||
log_dir = Path("logs")
|
||||
log_dir.mkdir(exist_ok=True)
|
||||
|
||||
# 日志配置
|
||||
with open(Path(__file__).with_name("logging.yaml"), "r", encoding="utf-8") as f:
|
||||
logconfig_dict = yaml.safe_load(f)
|
||||
|
||||
# 日志级别(debug、info、warning、error、critical);以 YAML 配置优先
|
||||
loglevel = "info"
|
||||
|
||||
# 访问日志文件("-" 表示输出到 stdout);以 YAML 配置优先
|
||||
accesslog = "logs/access.log"
|
||||
|
||||
# 错误日志文件;以 YAML 配置优先
|
||||
errorlog = "-"
|
||||
|
||||
# access_log_format 仅在 同步 worker 下有效,UvicornWorker下不可用;以 YAML 配置优先
|
||||
# access_log_format = '%(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s" %(D)s'
|
||||
raw_env = [
|
||||
"UVICORN_ACCESS_LOGFORMAT=%(h)s %(l)s %(u)s %(t)s \"%(r)s\" %(s)s %(b)s \"%(f)s\" \"%(a)s\" %(D)s"
|
||||
]
|
||||
|
||||
# 可选:超时时间(秒)
|
||||
timeout = 120
|
||||
|
||||
# Keep - Alive超时
|
||||
keepalive = 5
|
||||
|
||||
# 进程名(ps aux 中显示)
|
||||
# proc_name = "gunicorn"
|
||||
|
||||
# 守护进程运行(后台运行,默认 False)
|
||||
# daemon = True
|
||||
60
conf.default/logging.yaml
Normal file
60
conf.default/logging.yaml
Normal file
@@ -0,0 +1,60 @@
|
||||
version: 1
|
||||
disable_existing_loggers: false
|
||||
formatters:
|
||||
default:
|
||||
format: "[%(levelname)-7s] %(asctime)s [%(process)d] -[%(name)s:%(lineno)d] %(message)s"
|
||||
datefmt: "%Y-%m-%d %H:%M:%S"
|
||||
|
||||
handlers:
|
||||
console:
|
||||
class: logging.StreamHandler
|
||||
level: INFO
|
||||
formatter: default
|
||||
stream: ext://sys.stdout
|
||||
file_info:
|
||||
class: logging.handlers.TimedRotatingFileHandler
|
||||
level: INFO
|
||||
formatter: default
|
||||
filename: logs/info.log
|
||||
when: midnight
|
||||
interval: 1
|
||||
backupCount: 7
|
||||
encoding: utf8
|
||||
delay: true
|
||||
file_error:
|
||||
class: logging.handlers.TimedRotatingFileHandler
|
||||
level: ERROR
|
||||
formatter: default
|
||||
filename: logs/error.log
|
||||
when: midnight
|
||||
interval: 1
|
||||
backupCount: 7
|
||||
encoding: utf8
|
||||
delay: true
|
||||
|
||||
loggers:
|
||||
uvicorn:
|
||||
level: INFO
|
||||
handlers:
|
||||
- console
|
||||
- file_info
|
||||
propagate: false
|
||||
uvicorn.error:
|
||||
level: INFO
|
||||
handlers:
|
||||
- console
|
||||
- file_error
|
||||
propagate: false
|
||||
uvicorn.access:
|
||||
level: INFO
|
||||
handlers:
|
||||
- console
|
||||
- file_info
|
||||
propagate: false
|
||||
|
||||
root:
|
||||
level: INFO
|
||||
handlers:
|
||||
- console
|
||||
- file_info
|
||||
- file_error
|
||||
Reference in New Issue
Block a user