美文网首页
gunicorn部署flask--出现错误解决方案

gunicorn部署flask--出现错误解决方案

作者: 周周周__ | 来源:发表于2020-03-05 12:11 被阅读0次
常用的配置文件
import multiprocessing

bind = '0.0.0.0:8000'
backlog = 512
chdir = '/cwto_admin'
timeout = 30
worker_class = 'gevent'
workers = multiprocessing.cpu_count() * 2 + 1
threads = 2
loglevel = 'info'
access_log_format = '%(t)s %(p)s %(h)s "%(r)s" %(s)s %(L)s %(b)s %(f)s" "%(a)s"'
accesslog = "/logs/gunicorn_access.log"      # 访问日志文件
errorlog = "//logs/gunicorn_error.log"
启动命令

gunicorn -c gunicorn.conf.py wsgi:app

-c指定执行文件
wsgi是启动文件名称

ps:配置文件可在命令行使用,不做解释
如果配置启动得过程中出现错误

gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>

图片.png

在启动得时候加入命令:
如下:gunicorn wsgi:app -c /gunicorn.conf.py --log-level=debug
然后在我们配置的日志文件中可以找到错误进行准确定位:

错误

相关文章

网友评论

      本文标题:gunicorn部署flask--出现错误解决方案

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