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

常用的配置文件
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
然后在我们配置的日志文件中可以找到错误进行准确定位:

错误

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容