linux下gunicorn的安装配置笔记

安装

pip install gunicorn

配置

#config/***/gunicorn.py

bind = '127.0.0.1:15000'

# 是否后台运行
daemon = False

# 可选debug,info,warning,error,critical
loglevel = 'error'

# worker数量
workers = 1

# 报错日志的输入路径,'-'表示stderr输出
errorlog = '-'

# access log文件的保存路径,'-'代表stdout输出
accesslog = '-'

# worker处理请求耗时超过次值后重启
timeout = 30

# worker达到制定请求数后重启
max_requests = 10000

# worker类型配置,默认sync,还可以使用eventlet,gevent,tornado,gthread
worker_class = 'gevent'

运行

gunicorn -c config/***/gunicorn.py gunicon_server:application

Nginx 配置

upstream app_server {
    # for UNIX domain socket setups
    server unix:/tmp/gunicorn.sock fail_timeout=0;

    # for a TCP configuration
    # server 192.168.0.7:8000 fail_timeout=0;
  }
location {
	proxy_pass http://app_server;
}

这个application就是app = Flask(name)

参考

https://docs.gunicorn.org/en/latest/install.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值