美文网首页
Gunicorn常用配置参数

Gunicorn常用配置参数

作者: Rumple | 来源:发表于2019-05-22 13:05 被阅读0次

一、参数详解

  1. 指定一个配置文件(.py) -c --config

  2. 绑定socket -b --bind

    gunicorn -b 127.0.0.1:8080
    
  3. 守护进程后台运行 -D --daemon

  4. worker的数量 -w --workers

  5. 工作进程类型 -k

     工作进程类型包括:
         sync(default)
         eventlet
         gevent
         tornado
         gthread
         gaiohttp
    
  6. 最大挂起的连接数 --backlog

  7. 切换到指定的工作目录 --chdir

  8. 输出error log的颗粒度 --log-level

    有效颗粒度:
        debug
        info
        warning
        error
        critical
    
  9. 指定access日志文件 --access-logfile

  10. 指定error日志文件 --error-logfile

二、部署

  • 利用nginx反向代理
server {
    listen 80;
    server_name example.org;
    access_log  /var/log/nginx/example.log;

    location / {
        proxy_pass http://127.0.0.1:8000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
  }

相关文章

网友评论

      本文标题:Gunicorn常用配置参数

      本文链接:https://www.haomeiwen.com/subject/glwyzqtx.html