uWSGI + Gevent не получает запросы от Nginx - PullRequest
0 голосов
/ 15 апреля 2020

Я новичок в uWSGI / gevent, и у меня есть Python Flask Сервер с Flask -SocketIo, сидящим позади Nginx, и сервер, кажется, зависает всякий раз, когда запускается движок gevent l oop. Пример вывода показан ниже:

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;

}

}

1 Ответ

0 голосов
/ 16 апреля 2020

Проблема возникла из-за ошибки разрешения (после дополнительного копания с помощью команды sudo tail -30 /var/log/nginx/error.log)

Переход к файлу connect.ini и изменение chmod-socket = 660 на chmod-socket = 666 решило проблему.

...