如何使用 UWSGI_SCRIPT 动态地将 pylon 应用程序添加到 nginx 上的 uwsgi 进程?

发布于 2024-09-14 03:53:34 字数 1158 浏览 14 评论 0原文

我已经使用以下方法成功在 nginx + uwsgi 上部署了单个 pylons 应用程序:

uwsgi --paste config:/var/www/sites/helloworld/development.ini --socket :3031 -H /var/www/virtualenv

但是我正在使用 nginx 虚拟主机 3 个站点。

基于本教程和 uwsgi/wiki来自 unbit 上 uwsgi 主站点的 /DynamicApps 页面,我可以将应用程序动态添加到 uwsgi,而无需为 3 个独立端口上的 3 个主进程创建 3 个单独的 uwsgi init.d 脚本。

我的 nginx 虚拟主机配置的设置与教程中一样,但我在 UWSGI_SCRIPT 值方面遇到问题。我将其设置为 app.wsgi (位于 /var/www/sites/helloworld/app.wsgi )。脚本代码是:

from paste.deploy import loadapp
wsgi_app = loadapp('config:/var/www/sites/helloworld/development.ini')

但我找不到有关此脚本的任何直接信息。它应该被命名为 app_wsgi.py 还是完全不同的代码?它应该位于哪里? 当我访问该网站时,我得到:“uWSGI 错误 - 未找到 wsgi 应用程序”,然后我在 uwsgi.log 中看到以下内容:

interpreter for app 0 initialized.
ImportError: No module named app.wsgi
[pid: 7287|app: -1|req: -1/24] XXX.XXX.XXX.133 () {48 vars in 782 bytes} [Fri Aug 13 18:41:22 2010] GET /page/view/0 => generated 46 bytes in 8 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 async switches on async core 0)

I have successfully deployed a single pylons app on nginx + uwsgi using:

uwsgi --paste config:/var/www/sites/helloworld/development.ini --socket :3031 -H /var/www/virtualenv

However I am using nginx to virtual host 3 sites.

Based on this tutorial and the uwsgi/wiki/DynamicApps page from main uwsgi site on unbit, I can add apps dynamically to uwsgi without having to create 3 separate uwsgi init.d scripts for 3 master processes over 3 separate ports.

My nginx virtual host configurations are setup just like in the tutorial, but I am having a problem with the UWSGI_SCRIPT value. I have it set to app.wsgi (which is located at /var/www/sites/helloworld/app.wsgi). The script code is:

from paste.deploy import loadapp
wsgi_app = loadapp('config:/var/www/sites/helloworld/development.ini')

But I can't find any straightforward info about this script. Is it suppose to be named app_wsgi.py instead or different code altogether? And where is it supposed to be located?
When I visit the site I get: "uWSGI Error - wsgi application not found", then I see this in my uwsgi.log:

interpreter for app 0 initialized.
ImportError: No module named app.wsgi
[pid: 7287|app: -1|req: -1/24] XXX.XXX.XXX.133 () {48 vars in 782 bytes} [Fri Aug 13 18:41:22 2010] GET /page/view/0 => generated 46 bytes in 8 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 async switches on async core 0)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

混浊又暗下来 2024-09-21 03:53:34

它对我来说是这样的:

location / {
        include uwsgi_params;
        uwsgi_pass 127.0.0.1:5000;
        uwsgi_param UWSGI_PYHOME /home/don/dev/envs/pylons; #this is my virtualenv
        uwsgi_param UWSGI_CHDIR /home/don/dev/envs/pylons/apps/helloworld; #so app.py can be found
        uwsgi_param UWSGI_SCRIPT app; # app.py: where i put loadapp code
        uwsgi_param SCRIPT_NAME ""; # this line is needed, don't know what it means
}

然后使用 --vhost [--no-site] 启动 uwsgi,如果您使用主进程和工作进程启动 uwsgi,请记住在development.ini 中将 debug 设置为 false,此外还从 wsgi_app 重命名您的应用程序名称到应用程序,这就是 uwsgi 将要寻找的

it worked for me like this:

location / {
        include uwsgi_params;
        uwsgi_pass 127.0.0.1:5000;
        uwsgi_param UWSGI_PYHOME /home/don/dev/envs/pylons; #this is my virtualenv
        uwsgi_param UWSGI_CHDIR /home/don/dev/envs/pylons/apps/helloworld; #so app.py can be found
        uwsgi_param UWSGI_SCRIPT app; # app.py: where i put loadapp code
        uwsgi_param SCRIPT_NAME ""; # this line is needed, don't know what it means
}

then start uwsgi with --vhost [--no-site], remember to set debug to false in your development.ini if you start uwsgi with master and worker processes, besides rename your app name from wsgi_app to application, that's what uwsgi is going to look for

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文