uWSGI 无法加载虚拟环境

uWSGI 无法加载虚拟环境

我正在使用 nginx 和 uWSGI 设置 Python 应用程序。我的依赖项位于虚拟环境中。如果我手动激活虚拟环境,则运行以下命令即可正常运行:

uwsgi --ini uwsgi.ini

但是如果我尝试在停用虚拟环境的情况下运行相同的命令,我会在输出中得到以下信息(但没有特定的权限错误):

*** no app loaded. going in full dynamic mode ***

同样,当 Emperor 加载 ini 文件时,它无法运行该应用程序。我的理解是使用该home选项应该激活虚拟环境,但它似乎不起作用。(wsgi.py加载的模块也会激活虚拟环境,所以我甚至不确定为什么我需要在那之前这样做……)

这是我的uwsgi.ini

[uwsgi]
uid = 1000
socket = 127.0.0.1:8000
workers = 3
master = true
processes = 5
module = wsgi:application
chdir = /home/laststatement/app/laststatement
home = /home/laststatement/.virtualenvs/last
logto = /home/laststatement/log/uwsgi.log

以下是 uWSGI 日志:

machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 1
current working directory: /etc/uwsgi/apps-enabled
detected binary path: /usr/bin/uwsgi-core
uWSGI running as root, you can use --uid/--gid/--chroot options
setuid() to 1000
your processes number limit is 3750
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 TCP address 127.0.0.1:8000 fd 3
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 436752 bytes (426 KB) for 5 cores
*** Operational MODE: preforking ***
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
!!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!
no request plugin is loaded, you will not be able to manage requests.
you may need to install the package for your language of choice, or simply load it with --plugin.
!!!!!!!!!!! END OF WARNING !!!!!!!!!!
spawned uWSGI master process (pid: 834)
spawned uWSGI worker 1 (pid: 838, cores: 1)
spawned uWSGI worker 2 (pid: 839, cores: 1)
spawned uWSGI worker 3 (pid: 840, cores: 1)
spawned uWSGI worker 4 (pid: 841, cores: 1)
spawned uWSGI worker 5 (pid: 842, cores: 1)
-- unavailable modifier requested: 0 --
announcing my loyalty to the Emperor...
-- unavailable modifier requested: 0 --
announcing my loyalty to the Emperor...

答案1

你显然运行了 2 个不同的 uWSGI 版本。一个在虚拟环境中,嵌入了 python 插件,另一个在系统范围内,你没有为其加载 python 插件:

!!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!! no request plugin is loaded, you will not be able to manage requests. you may need to install the package for your language of choice, or simply load it with --plugin. !!!!!!!!!!! END OF WARNING !!!!!!!!!!

只需安装 uwsgi python 插件并使用 plugin = python 启用它

相关内容