如何使用 UWSGI_SCRIPT 动态地将 pylon 应用程序添加到 nginx 上的 uwsgi 进程?
我已经使用以下方法成功在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它对我来说是这样的:
然后使用 --vhost [--no-site] 启动 uwsgi,如果您使用主进程和工作进程启动 uwsgi,请记住在development.ini 中将 debug 设置为 false,此外还从 wsgi_app 重命名您的应用程序名称到应用程序,这就是 uwsgi 将要寻找的
it worked for me like this:
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