如何配置uWSGI站点以使用与构建uWSGI不同的Python解释器? (uWSGI virtualenv皇帝)

我们的应用程序是为Python 2.7编写的.它具有一个配置为使用Python 2.7的virtualenv.系统安装的uWSGI是使用Python 2.6构建的. It seems that this is a problem.我们可以卸载/重新安装uWSGI以使用Python 2.7,但是当我们最终拥有Python 3站点时会发生什么?这不是virtualenv的目的吗?我们可以在virtualenv中安装一个单独的uWSGI实例,但是尚不清楚它是如何工作的-需要在启动时激活它,以及如何与皇帝一起使用?我们应该使用uWSGI关键字“ unprivileged-binary-patch”吗?

我们如何配置uWSGI,以便我们可以使用不同的Python解释器运行多个应用程序?

从uWSGI启动时,我们会看到此问题.

Python version: 2.6.9 (unknown, Oct 29 2013, 19:58:13)  [GCC 4.6.3 20120306 (Red
 Hat 4.6.3-2)]
Set PythonHome to /var/local/virtualenv/myapp
Python main interpreter initialized at 0xf86790
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 655200 bytes (639 KB) for 8 cores
*** Operational MODE: preforking ***
initialized 137 metrics
Traceback (most recent call last):
  File "/var/local/myapp/cgi/myapp.wsgi", line 6, in <module>
    from myapp import create_app
  File "./myapp/__init__.py", line 3, in <module>
    from app import create_app
  File "./myapp/app.py", line 1, in <module>
    import os
ImportError: No module named os
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
gracefully (RE)spawned uWSGI master process (pid: 2500)
spawned uWSGI worker 1 (pid: 2521, cores: 1)
spawned uWSGI worker 2 (pid: 2522, cores: 1)
spawned uWSGI worker 3 (pid: 2523, cores: 1)
spawned uWSGI worker 4 (pid: 2524, cores: 1)
spawned uWSGI worker 5 (pid: 2525, cores: 1)
spawned uWSGI worker 6 (pid: 2526, cores: 1)
spawned uWSGI worker 7 (pid: 2527, cores: 1)
spawned uWSGI worker 8 (pid: 2528, cores: 1)
metrics collector thread started
*** Stats server enabled on 127.0.0.1:9191 fd: 27 ***
spawned uWSGI http 1 (pid: 2530)

该应用程序是用Flask编写的,并且正在使用create_app模式启动它.当使用virtualenv和端口5000上的Flask内置的开发人员Web服务器时,该应用程序运行良好.

ini文件如下所示:

[uwsgi]
chdir = /var/local/%n
callable = create_app
virtualenv=/var/local/virtualenv/%n
wsgi-file = /var/local/%n/cgi/%n.wsgi
master = true
daemonize = /var/log/uwsgi/%n.log
pidfile = /var/run/uwsgi/%n.pid
http = :9090

我们要以皇帝模式运行该站点.这是皇帝ini文件:

[uwsgi]
emperor = /etc/uwsgi/vassals

pidfile = /var/run/uwsgi/%n.pid
daemonize = /var/log/uwsgi/%n.log

解决方法:

最好的方法是为每个python版本都有一个uWSGI插件(例如您发行版中的uWSGI软件包)

(旧网站上的文档)
http://projects.unbit.it/uwsgi/wiki/MultiPython

上一篇:我需要为新的virtualenv重新安装Django吗?


下一篇:python-在无法访问pypi的计算机上使用virtualenv