Files
Django/gunicorn.conf.py
T

52 lines
1.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# /opt/1panel/apps/openresty/nginx/www/sites/43.142.166.152.443/django/gunicorn.conf.py
# 绑定的IP和端口(根据你的Nginx配置,后端在8001端口)
bind = "127.0.0.1:8001"
# 工作进程数(根据CPU核心数调整,建议:CPU核心数*2+1)
# 查看CPU核心数:cat /proc/cpuinfo | grep "processor" | wc -l
workers = 4
# 工作模式(使用gevent支持异步,更高效)
#worker_class = "gevent"
worker_class = "sync" # 改成这个
# 每个worker的最大请求数(防止内存泄漏)
max_requests = 1000
max_requests_jitter = 50 # 随机抖动,避免所有worker同时重启
# 超时时间(秒)
timeout = 30
keepalive = 2
# 预加载应用(减少内存占用,加快请求处理)
preload_app = True
# 日志配置
# 访问日志:输出到标准输出,便于OnePanel查看
accesslog = "-"
# 错误日志:输出到标准错误
errorlog = "-"
# 日志级别
loglevel = "info"
# 进程名称(便于识别)
proc_name = "a_long_dianjing_gunicorn"
# 工作进程的用户/组(安全考虑,用非root用户运行)
# user = "www-data"
# group = "www-data"
# 工作进程临时目录(避免权限问题)
worker_tmp_dir = "/dev/shm"
# 限制请求数据大小(防止大文件攻击)
limit_request_line = 4094
limit_request_fields = 100
limit_request_field_size = 8190
# 优雅退出时间
graceful_timeout = 30
# 进程守护(如果用systemd管理,这里设为False)
daemon = False