我們的應用程序是爲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站點以使用不同於使用uWSGI構建的不同Python解釋器? (uWSGI + virtualenv + emperor)
我們如何配置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和開發Web服務器內置到燒瓶中,在端口5000
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
有人用同樣的問題::http://www.eonlinegratis.com/2013/deploying-flask-application-with-nginx-uwsgi-and-virtualenv那麼您可以在堆疊模式下使用uwsgi皇帝/ #sthash.IVWl0SyA.dpbs – 010110110101