Running multiple uwsgi python versions

I'm trying to deploy django with uwsgi, and I think I lack understanding of how it all works. I have uwsgi running in emperor mode, and I'm trying to get the vassals to run in their own virtualenvs, with a different python version.

The emperor configuration:

[uwsgi]
socket = /run/uwsgi/uwsgi.socket
pidfile = /run/uwsgi/uwsgi.pid
emperor = /etc/uwsgi.d
emperor-tyrant = true
master = true
autoload = true
log-date = true
logto = /var/log/uwsgi/uwsgi-emperor.log

And the vassal:

uid=django
gid=django
virtualenv=/home/django/sites/mysite/venv/bin
chdir=/home/django/sites/mysite/site
module=mysite.uwsgi:application
socket=/tmp/uwsgi_mysite.sock
master=True

I'm seeing the following error in the emperor log:

Traceback (most recent call last):
  File "./mysite/uwsgi.py", line 11, in <module>
    import site
ImportError: No module named site

The virtualenv for my site is created as a python 3.4 pyvenv. The uwsgi is the system uwsgi (python2.6). I was under the impression that the emperor could be any python version, as the vassal would be launched with its own python and environment, launched by the master process. I now think this is wrong.

What I'd like to be doing is running the uwsgi master process with the system python, but the various vassals (applications) with their own python and their own libraries. Is this possible? Or am I going to have to run multiple emperors if I want to run multiple pythons? Kinda defeats the purpose of having virtual environments.


The "elegant" way is building the uWSGI python support as a plugin, and having a plugin for each python version:

(from uWSGI sources)

make PROFILE=nolang

(will build a uWSGI binary without language support)

PYTHON=python2.7 ./uwsgi --build-plugin "plugins/python python27"

will build the python27_plugin.so that you can load in vassals

PYTHON=python3 ./uwsgi --build-plugin "plugins/python python3"

will build the plugin for python3 and so on.

There are various way to build uWSGI plugins, the one i am reporting is the safest one (it ensure the #ifdef are honoured).

Having said that, having a uWSGI Emperor for each python version is viable too. Remember Emperor are stackable, so you can have a generic emperor spawning one emperor (as its vassal) for each python version.

链接地址: http://www.djcxy.com/p/65936.html

上一篇: 除非是root,否则uWSGI Emperor权限被拒绝

下一篇: 运行多个uwsgi python版本