uwsgi选项--wsgi-file和--module无法识别

aaa*_*210 20 wsgi django-wsgi uwsgi

我正在尝试使用uwsgi运行Django应用程序.我发现的大多数指令都引用了"--wsgi-file"和"--module"来指定应用程序,但是"uwsgi"没有提到这些选项,当我尝试使用它们时:

uwsgi -s /tmp/uwsgi.sock --master --module myapp.wsgi
uwsgi: unrecognized option '--module'
getopt_long() error
Run Code Online (Sandbox Code Playgroud)

uwsgi -s /tmp/uwsgi.sock --master --wsgi-file myapp/wsgi.py
uwsgi: unrecognized option '--wsgi-file'
getopt_long() error
Run Code Online (Sandbox Code Playgroud)

当我没有任何一个运行时,我得到:

uwsgi -s /tmp/uwsgi.sock --master 
*** Starting uWSGI 2.0.9 (64bit) on [Fri Jul 10 11:12:04 2015] ***
compiled with version: 4.4.7 20120313 (Red Hat 4.4.7-11) on 23 April 2015 19:31:15
os: Linux-2.6.32-504.16.2.el6.x86_64 #1 SMP Tue Mar 10 17:01:00 EDT 2015
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 2
detected binary path: /usr/sbin/uwsgi
your processes number limit is 1024
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 /tmp/uwsgi.sock fd 5
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 145536 bytes (142 KB) for 1 cores
*** Operational MODE: single process ***
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 26597)
spawned uWSGI worker 1 (pid: 26598, cores: 1)
Run Code Online (Sandbox Code Playgroud)

为什么这些选项不被认可?我该如何指定要加载的应用程序?这是什么样的垃圾软件?我应该回去使用Gunicorn吗?

Wer*_*ght 39

这意味着未安装或加载uWSGI 的python插件.要验证运行:

$ uwsgi --plugins-list
Run Code Online (Sandbox Code Playgroud)

一般来说,如果你有build-essential python-dev等,你可以通过以下方式安装:

$ pip install uwsgi
Run Code Online (Sandbox Code Playgroud)

DebianUbuntu上,您也可以通过以下方式安装它:

$ apt-get install uwsgi-plugin-python
Run Code Online (Sandbox Code Playgroud)

Linux Alpine上,您当前必须指定它的位置:

$ apk add --update uwsgi-python
$ uwsgi --plugins-dir /usr/lib/uwsgi/ --need-plugin python --plugins-list
*** uWSGI loaded generic plugins ***

*** uWSGI loaded request plugins ***
0: python
...
Run Code Online (Sandbox Code Playgroud)

您也可以通过以下方式指定其完整路径:

$ uwsgi --plugin /usr/lib/uwsgi/python_plugin.so --plugins-list
Run Code Online (Sandbox Code Playgroud)

  • 仍然不适合我.安装`uwsgi-plugin-python`和`uwsgi-plugin-python3`后运行`uwsgi -http-socket:9090 --wsgi-file ./respond.py --plugin/usr/lib/uwsgi/plugins/python3_plugin.so`仍然让我得到"无法识别的选项"响应. (3认同)
  • @Shadur帮助我解决类似问题的方法是在任何特定于插件的参数之前指定`--plugin ...`参数。在您的情况下,您可以尝试:`uwsgi --http-socket:9090 --plugin /usr/lib/uwsgi/plugins/python3_plugin.so --wsgi-file ./respond.py` (2认同)