uWSGI + Gevent未从Nginx接收请求

问题描述 投票:0回答:1

我是uWSGI / gevent的新手,我的Python Flask服务器的Flask-SocketIo位于Nginx的后面,每当gevent的循环引擎运行时,该服务器就会死机。输出示例如下:

compiled with version: 7.5.0 on 15 April 2020 12:57:22
os: Linux-4.15.0-96-generic #97-Ubuntu SMP Wed Apr 1 03:25:46 UTC 2020
nodename: xxxxxxxxxx
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 1
current working directory: /home/admin/myapplication
detected binary path: /home/admin/myapplication/venv/bin/uwsgi
your processes number limit is 3838
your memory page size is 4096 bytes
detected max file descriptor number: 1024
- async cores set to 1000 - fd table size: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address connect.sock fd 3
Python version: 3.6.9 (default, Nov  7 2019, 10:44:02)  [GCC 8.3.0]
Python main interpreter initialized at 0x55701b9d6e40
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 21036928 bytes (20543 KB) for 1000 cores
*** Operational MODE: async ***
WSGI app 0 (mountpoint='') ready in 1 seconds on interpreter 0x55701b9d6e40 pid: 2692 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 2692)
spawned uWSGI worker 1 (pid: 2710, cores: 1000)
*** running gevent loop engine [addr:0x557019f92410] ***

至此,尽管我试图访问该页面(在此我得到一个错误502 Bad Gateway),该程序仍未产生进一步的输出。

该应用是通过服务文件运行的,当我直接从命令行运行该应用时,它似乎可以正常运行。谁能在我的代码中找到问题? (提前感谢)

这里是我的服务文件的副本:

connect.service

[Unit]
Description= xxxxxxxxxxxx
After=network.target

[Service]
User=admin
Group=www-data
WorkingDirectory=/home/admin/myapplication
Environment="PATH=/home/admin/myapplication/venv/bin"
ExecStart=/home/admin/myapplication/venv/bin/uwsgi --ini service_files/connect.ini

[Install]
WantedBy=multi-user.target

connect.ini

[uwsgi]
module = wsgi:app

master = true
gevent = 1000
http-websockets = true

socket = connect.sock
chmod-socket = 660
vacuum = true
logto = /home/admin/myapplication/service_files/logs/uwsgi/%n.log

die-on-term = true

Nginx网站

server {

listen 80;

server_name subdomain.domain.com;

return 301 https://$server_name$request_uri;

}

server {

listen 443 ssl;

ssl_certificate /home/admin/myapplication/service_files/connect.crt;

ssl_certificate_key /home/admin/myapplication/service_files/connect.key;

server_name subdomain.domain.com;

location / {

include uwsgi_params;
uwsgi_pass unix:///home/admin/myapplication/connect.sock;

}

location /socket.io/ {

proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
include uwsgi_params;
uwsgi_pass unix:///home/admin/myapplication/connect.sock;

}

}
python-3.x nginx uwsgi gevent flask-socketio
1个回答
0
投票

此问题是由于权限错误(在使用命令sudo tail -30 /var/log/nginx/error.log进行更多挖掘之后]

转到connect.ini文件并将chmod-socket = 660更改为chmod-socket = 666解决了该问题。

© www.soinside.com 2019 - 2024. All rights reserved.