为什么uwsgi在卷曲时会返回空?

时间:2018-05-30 13:25:34

标签: python flask uwsgi

我有一个Flask Uwsgi部署

直到今天才工作正常

服务器的卷曲将低于

curl http://ip:5000/api -i
curl: (52) Empty reply from server

uwsgi日志显示在下面(请不要再说检查日志了。日志已在这里)

[pid: 15778|app: 0|req: 552000/854000] 8.8.8.8 () {22 vars in 241 bytes} [Wed May 30 16:40:51 2018] HEAD / => generated 0 bytes in 0 msecs (HTTP/1.0 404) 2 headers in 72 bytes (0 switches on core 0)
...The work of process 15778 is done. Seeya!
worker 1 killed successfully (pid: 15778)
Respawned uWSGI worker 1 (new pid: 18478

此问题也与问题不重复 Django, uWSGI & nginx: Process dies for "no reason"

那个原因是他有一个设置

--max-requests 10

他没有主人设定。因此,在他的日志中,您可以看到达到限制的req 1000/1000。我不是!!!

我在我的conf中设置了master = true,你也可以从wsgi日志中看到。没达到最大要求!!!

uwsgi的配置如下所示

[uwsgi]
socket = /opt/CephMGRServer/ceph_mgr_server/var/tmp/uwsgi.sock
http= 0.0.0.0:5000
chdir=/opt/CephMGRServer/ceph_mgr_server
wsgi-file = app.py
callable=app
master = true
processes=2
threads=2
max-requests=2000
chmod-socket=664
vacuum=true
daemonize = /opt/CephMGRServer/ceph_mgr_server/var/log/uwsgi.log

我可以看到进程仍在那里并且正在监听5000端口

ps -ef | grep wsgi| grep -v grep| grep -v tail
root      2083 22075  0 May28 ?        00:00:00 uwsgi --ini /opt/CephMGRServer/ceph_mgr_server/conf/wsgi.ini
root     18478 22075  0 16:40 ?        00:00:00 uwsgi --ini /opt/CephMGRServer/ceph_mgr_server/conf/wsgi.ini
root     22075     1  0 May24 ?        00:02:50 uwsgi --ini /opt/CephMGRServer/ceph_mgr_server/conf/wsgi.ini
root     22090 22075  0 May24 ?        00:01:48 uwsgi --ini /opt/CephMGRServer/ceph_mgr_server/conf/wsgi.ini

虽然值得注意的是只有两个进程监听5000和uwsgi有4个进程

lsof -i:5000
COMMAND   PID USER   FD   TYPE   DEVICE SIZE/OFF NODE NAME
uwsgi   22075 root    3u  IPv4 76455578      0t0  TCP *:commplex-main (LISTEN)
uwsgi   22090 root    3u  IPv4 76455578      0t0  TCP *:commplex-main (LISTEN)

那么uwsig发生了什么以及如何检查?

1 个答案:

答案 0 :(得分:0)

您不能直接查询。 您应该在NGINX配置中配置上游,并指向您的uwsgi unix / tcp套接字

或者仅通过http / https套接字运行uwsgi

像这样的东西uwsgi --ini uwsgi.ini --httpsocket 80(无法调用正确的选项)