Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/320.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何配置uWSGI站点以使用不同于uWSGI构建时使用的Python解释器?(uWSGI+;virtualenv+;皇帝)_Python_Flask_Virtualenv_Uwsgi - Fatal编程技术网

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

如何配置uWSGI站点以使用不同于uWSGI构建时使用的Python解释器?(uWSGI+;virtualenv+;皇帝),python,flask,virtualenv,uwsgi,Python,Flask,Virtualenv,Uwsgi,我们的应用程序是为Python 2.7编写的。它有一个配置为使用Python 2.7的virtualenv。系统安装的uWSGI是使用Python 2.6构建的。我们可以卸载/重新安装uWSGI以使用Python2.7,但是当我们最终拥有Python3站点时会发生什么呢?这不是virtualenv的作用吗?我们可以在virtualenv中安装一个单独的uWSGI实例,但不清楚它是如何工作的——需要在启动时激活它,以及如何与帝王一起工作?我们应该使用uWSGI关键字“非特权二进制补丁”吗 如何配置

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

如何配置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)
我们想在帝王模式下运行该站点。这是您的ini文件:

[uwsgi]
emperor = /etc/uwsgi/vassals

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

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

(旧站点上的文档)

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

[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

我试过了,结果卡住了。要做到这一点,我们需要从源代码构建,然后知道除了python插件之外还需要构建哪些插件。有名单吗?我在你的想法上取得了部分成功(谢谢!)我最初使用pip安装uWSGI这导致了一些插件的组合,但使用默认python(这是我的问题)。你的想法需要从源代码安装它,但我需要知道还需要编译哪些其他插件(我得到一个错误,没有这样的请求插件——我猜“核心”没有)部署python应用程序时,你只需要python插件(每个python版本一个),没有“加载请求插件”因为您没有在选项中添加“plugin”选项来告诉uWSGI内核要加载哪个插件,所以我尝试将plugins=python27行添加到vassal的ini文件中。uWSGI抱怨它找不到该插件文件。因此,我从安装的同一源代码中构建了该插件——但将其放在哪里?因此我还添加了plugins dir=/place/where/python27/plugin/保存到vassal的ini文件中。这没有出错,但是python版本没有被加载。它仍然报告2.6.X。
[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