Согласование глобальных и виртуальных установок uWSGI - PullRequest
1 голос
/ 28 октября 2019

Развертывание бэкэнда Django на Ubuntu 18.04 AWS EC2. uWSGI, NGINX и Django (все) отлично работают, когда я запускаю из виртуальной среды моей оболочки pipenv. Когда я пытаюсь использовать глобальную установку uWSGI для автоматического запуска, происходит сбой uWSGI с явно распространенной ошибкой «модуль не найден». Системный питон Ubuntu - 2.7.15. Мое приложение работает под управлением 3.7.3 и запускает виртуальную установку uWSGI, скомпилированную с 3.7.3.

Я скомпилировал здесь плагин uWSGI для python3: https://www.paulox.net/2019/03/13/how-to-use-uwsgi-with-python-3-7-in-ubuntu-18-x/ Он запускается, но по-прежнему сообщает с использованием Python 2.7 (см. пример ниже).

Я создал .ini и перепробовал так много разных комбинаций настроек, что потерял из виду какие. Я попытался установить виртуальную среду в пути Python дважды. Я пытался установить различные двоичные файлы uWSGI. Я настроил разрешения. Вот как это выглядит в настоящее время:

[uwsgi]
pythonpath=/home/dpcii/.local/share/virtualenvs/tube-backend-django-S2uZEC9-/lib/python3.7/site-packages
pythonpath=/home/dpcii/.local/share/virtualenvs/tube-backend-django-S2uZEC9-/lib/python3.7/site-packages
plugins=python37
binary-path=/usr/bin/uwsgi
virtualenv=/home/dpcii/.local/share/virtualenvs/tube-backend-django-S2uZEC9-
pythonpath=/home/dpcii/.local/share/virtualenvs/tube-backend-django-S2uZEC9-/lib/python3.7/site-packages
chdir=/home/dpcii/tube-backend-django/
module=video_backend.wsgi:application
home=/home/dpcii/.local/share/virtualenvs/tube-backend-django-S2uZEC9-

master=false
processes=10
threads=2
socket=video_backend.sock
chmod-socket=666
vacuum=true

Когда я запускаю Император, используя глобальный (вместо среды Python) исполняемый файл uWSGI, вот что я получаю:

*** Starting uWSGI 2.0.15-debian (64bit) on [Mon Oct 28 12:57:50 2019] ***
compiled with version: 7.3.0 on 28 September 2018 15:41:15
os: Linux-4.15.0-1051-aws #53-Ubuntu SMP Wed Sep 18 13:35:53 UTC 2019
nodename: ip-172-30-0-12
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 1
current working directory: /etc/uwsgi/vassals
detected binary path: /usr/bin/uwsgi
dropping root privileges as early as possible
chdir() to /home/dpcii/tube-backend-django/
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 3841
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address video_backend.sock fd 3
dropping root privileges after socket binding
Python version: 2.7.15+ (default, Oct  7 2019, 17:39:04)  [GCC 7.4.0]
Set PythonHome to /home/dpcii/.local/share/virtualenvs/tube-backend-django-S2uZEC9-
ImportError: No module named site
VACUUM: unix socket video_backend.sock removed.
Mon Oct 28 12:57:50 2019 - [emperor] curse the uwsgi instance twstartup.ini (pid: 21180)
Mon Oct 28 12:57:53 2019 - [emperor] removed uwsgi instance twstartup.ini

Этоэто ответ, который я получаю от установки рабочей среды:

[uWSGI] getting INI configuration from twstartup.ini
open("./python37_plugin.so"): No such file or directory [core/utils.c line 3724]
!!! UNABLE to load uWSGI plugin: ./python37_plugin.so: cannot open shared object file: No such file or directory !!!
*** Starting uWSGI 2.0.18 (64bit) on [Mon Oct 28 13:45:44 2019] ***
compiled with version: 7.4.0 on 27 October 2019 18:59:30
os: Linux-4.15.0-1051-aws #53-Ubuntu SMP Wed Sep 18 13:35:53 UTC 2019
nodename: ip-172-30-0-12
machine: x86_64
clock source: unix
detected number of CPU cores: 1
current working directory: /home/dpcii/tube-backend-django
detected binary path: /usr/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
chdir() to /home/dpcii/tube-backend-django/
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 3841
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address video_backend.sock fd 3
Python version: 3.7.3 (default, Apr  3 2019, 19:16:38)  [GCC 8.0.1 20180414 (experimental) [trunk revision 259383]]
Set PythonHome to /home/dpcii/.local/share/virtualenvs/tube-backend-django-S2uZEC9-
Python main interpreter initialized at 0x55e9527ff860
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 833440 bytes (813 KB) for 20 cores
*** Operational MODE: preforking+threaded ***
added /home/dpcii/.local/share/virtualenvs/tube-backend-django-S2uZEC9-/lib/python3.7/site-packages/ to pythonpath.
added /home/dpcii/.local/share/virtualenvs/tube-backend-django-S2uZEC9-/lib/python3.7/site-packages/ to pythonpath.
added /home/dpcii/.local/share/virtualenvs/tube-backend-django-S2uZEC9-/lib/python3.7/site-packages/ to pythonpath.
WSGI app 0 (mountpoint='') ready in 1 seconds on interpreter 0x55e9527ff860 pid: 21229 (default app)
*** uWSGI is running in multiple interpreter mode ***

Такое чувство, что я танцую вокруг ответа. У меня есть только ноготь на пути к Python env и символическим ссылкам, так что, возможно, есть что-то очевидное, что я упускаю.

...