# -*- coding: utf-8 -*- """gunicorn 生产配置。 为什么不是多 worker:app.py 在模块级启动 APScheduler(清理/指标任务),多进程会 让同一批定时任务在每个 worker 里各跑一遍。这里用「单 worker + 多线程」,既保证 定时任务只跑一次,又让并发上传互不阻塞(上传是 I/O 密集,GIL 在 read/write 时释放)。 超时给到 1 小时:400MB 在移动网络下光传输就可能十几分钟,之后的落盘也不能被打断。 """ import os bind = "0.0.0.0:8080" workers = 1 worker_class = "gthread" threads = int(os.environ.get("UPLOAD_THREADS", "16")) timeout = int(os.environ.get("UPLOAD_TIMEOUT", "3600")) graceful_timeout = 120 keepalive = 75 # worker 心跳放 tmpfs,避免和附件写盘抢 IO worker_tmp_dir = "/dev/shm" limit_request_line = 0 limit_request_field_size = 0 limit_request_fields = 200 accesslog = "-" errorlog = "-" loglevel = os.environ.get("UPLOAD_LOG_LEVEL", "info") access_log_format = '%(h)s "%(r)s" %(s)s %(b)s %(L)s "%(a)s"' forwarded_allow_ips = "*"