Created
September 24, 2020 09:31
-
-
Save ixuuux/378e962fe7aaab59dbdc8f712d0e33ec to your computer and use it in GitHub Desktop.
gunicorn 配置示例说明
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import multiprocessing | |
# example: | |
# gunicorn app:app -b localhost:10021 -w 3 -D -k uvicorn.workers.UvicornWorker --error-logfile ./logs/gunicorn_error.log --log-level warning | |
# 并行工作进程数 | |
workers = multiprocessing.cpu_count()*2+1 # -w 3 | |
# 监听内网端口 | |
bind = '0.0.0.0:8000' # -b 0.0.0.0:8000 | |
# 设置守护进程 | |
daemon = True # -D | |
# 工作模式协程 | |
worker_class = 'uvicorn.workers.UvicornWorker' # -k uvicorn.workers.UvicornWorker | |
# 记录 gunicorn 主进程 id 到文件 | |
# 可通过操作此文件重启、关机 gunicorn | |
# 重启:kill -HUP ./pid.pid | |
# 关机:kill -TERM ./pid.pid | |
pidfile = './pid.pid' | |
# 启动异常日志记录,及级别 | |
errorlog = './logs/gunicorn_error.log' # --error-logfile ./logs/gunicorn_error.log | |
loglevel = 'warning' # --log-level warning |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment