首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何将uWSGI站点配置为使用不同的uWSGI解释器而不是用什么构建uWSGI?(uWSGI + virtualenv +皇帝)

如何将uWSGI站点配置为使用不同的uWSGI解释器而不是用什么构建uWSGI?(uWSGI + virtualenv +皇帝)
EN

Stack Overflow用户
提问于 2013-11-20 15:21:44
回答 2查看 4.7K关注 0票数 3

我们的应用程序是为Python2.7编写的。它有一个virtualenv,配置为使用Python2.7。系统安装的uWSGI是用Python2.6构建的。It seems that this is a problem.我们可以卸载/重新安装uWSGI以使用Python2.7,但是当我们最终拥有Python3站点时会发生什么呢?这不是虚拟人的目的吗?我们可以在virtualenv中安装一个单独的uWSGI实例,但是还不清楚它是如何工作的--需要在启动时激活它,以及如何与皇帝一起工作呢?我们应该使用uWSGI关键字“非特权-二进制补丁”吗?

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

当从uWSGI启动时,我们看到了这个问题。

代码语言:javascript
复制
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)

这个应用程序是用烧瓶编写的,并且使用create_app模式来启动它。当使用virtualenv和内置在端口5000上的Flask中的开发者web服务器时,这个应用程序工作得很好。

ini文件如下所示:

代码语言:javascript
复制
[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

我们想以皇帝的方式运行这个网站。这是皇帝的档案:

代码语言:javascript
复制
[uwsgi]
emperor = /etc/uwsgi/vassals

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

回答 2

Stack Overflow用户

发布于 2013-11-21 05:49:16

最好的方法是为每个python版本提供一个uWSGI插件(比如发行版中的uWSGI包)。

(老网站上的医生) http://projects.unbit.it/uwsgi/wiki/MultiPython

票数 2
EN

Stack Overflow用户

发布于 2016-04-19 18:21:38

您可以在其他python/virtualenv版本中安装uwsgi。然后,您可以在堆栈模式下使用uwsgi皇帝:

代码语言:javascript
复制
[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
unprivileged-binary-patch = /var/local/virtualenv/bin/uwsgi
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20099858

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档