gunicorn Python部署应用

对于flask应用python

启动命令为 python app.pyflask

 

使用gunicorn启动app

pip install gunicorndebug

python gunicorn --workers=7 switch_app:app -b 0.0.0.0:6002日志

 

 

将gunicorn的配置参数写入文件 config.py对象

python gunicorn -c config.py switch_app:app进程

其中switch_app为文件名 switch_app.py  ,app为文件中的app对象ip

 

 

config.py的代码以下ssl

import os it

import gevent.monkey

gevent.monkey.patch_all()

import multiprocessing

#debug = True

loglevel = 'debug'

bind = "0.0.0.0:6002"

pidfile = "logs/gunicorn.pid"

accesslog = "logs/access.log"

errorlog = "logs/debug.log"

daemon = True

timeout = 180

#启动进程数

workers=multiprocessing.cpu_count()

worker_class = 'gevent'

x_forwarded_for_header = 'X-FORWARDED-FOR'

 

 

其中timeout=180表示超过180秒未反应就关闭该请求响应,会获得请求被异常关闭的日志信息,默认超时时间为60秒左右

相关文章
相关标签/搜索