解决一例uWSGI假死问题

这个问题很有意思。

症状是,如果使用Python启动Flask,没有任何问题;但是使用uWSGI带着gevent启动app,到一定时间后,这个uWSGI就收不到任何请求了。

这是使用的命令:

uwsgi3 --gevent 8 --gevent-monkey-patch --http :1234 -s /tmp/uwsgi.sock --pythonpath=~/api/ -w new_api:app

uwsgi3 --gevent 8 --gevent-monkey-patch --http :1234 -s /tmp/uwsgi.sock --pythonpath=~/api/ -w new_api:app

有意思的地方在于,刚开始在排查的时候,由于uWSGI没有任何错误提示,很容易误以为是Python3和Python2兼容的问题,或者是gevent的问题。

 

但其实是由于启动时参数不对。应该是--http-socket。

uwsgi3 --gevent 8 --gevent-monkey-patch --http-socket :1234 -s /tmp/uwsgi.sock --pythonpath=~/api/ -w new_api:app

这样就对了。

 

http://uwsgi-docs.readthedocs.io/en/latest/WSGIquickstart.html

在官方文档里也写了这个问题。

Do not use --http when you have a frontend webserver or you are doing some form of benchmark, use --http-socket. Continue reading the quickstart to understand why.

转载于:https://www.cnblogs.com/FRank5433/p/6323698.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值