我正在使用 nginx 和 uWSGI 设置 Python 应用程序。我的依赖项位于 virtualenv 中。如果我手动激活 virtualenv,一切都可以通过运行以下命令进行:
uwsgi --ini uwsgi.ini
但是如果我尝试在 virtualenv 停用的情况下运行相同的命令,我会在输出中得到这个(虽然没有特定的权限错误):
*** no app loaded. going in full dynamic mode ***
同理,Emperor加载ini文件时,也无法运行app。我的理解是使用该home
选项应该激活 virtualenv,但它似乎没有工作。(wsgi.py
加载的模块也会激活 virtualenv,所以我什至不确定为什么我应该在那之前这样做......)
这是我的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...
您显然正在运行 2 个不同的 uWSGI 版本。一个在 virtualenv 中嵌入了 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 启用它