粘贴配置中的基本路径

发布于 2024-11-05 12:35:19 字数 804 浏览 1 评论 0原文

我正在尝试将一些 Pyramid 代码部署到 dotcloud。不幸的是,某些路径的映射方式与本地粘贴器部署中的方式不同。当我通过pasterserve...在本地服务器上运行开发配置时,我可以访问以下配置的静态文件:

config.add_static_view('static', 'appname:static')

但是在dotcloud服务器上,当脚本通过以下wsgi运行时.py

import os, sys
from paste.deploy import loadapp
current_dir = os.path.dirname(__file__)
application = loadapp('config:production.ini', relative_to=current_dir)

在错误的目录中搜索静态内容。它应该在 /home/dotcloud/current/appname/static/pylons.css 中查找,而不是 /home/dotcloud/current/static/pylons.css

wsgi 配置的一部分可以定义基本目录?我缺少什么?该应用程序通过 nginx / uwsgi 运行。

我尝试加载 config:../development.ini, relative_to=current_dir + '/appname' 但这并没有改变任何东西。

I'm trying to deploy some Pyramid code to dotcloud. Unfortunately some paths are not mapped in the same way as in local paster deployment. When I'm running the development configuration with local server through paster serve ..., I can access static files configured in:

config.add_static_view('static', 'appname:static')

however on the dotcloud servers, when the scripts run via the following wsgi.py:

import os, sys
from paste.deploy import loadapp
current_dir = os.path.dirname(__file__)
application = loadapp('config:production.ini', relative_to=current_dir)

static content is searched for in a wrong directory. Instead of /home/dotcloud/current/static/pylons.css, it should look in /home/dotcloud/current/appname/static/pylons.css

Is there some part of wsgi configuration which can define the base directory? What am I missing? The application is run via nginx / uwsgi.

I tried to load config:../production.ini, relative_to=current_dir + '/appname' but that didn't change anything.

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

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

发布评论

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

评论(1

无力看清 2024-11-12 12:35:19

在 DotCloud 上,以 /static 开头的 URL 直接由 nginx 处理,而不是由 uwsgi 处理。这意味着您的代码永远不会看到这些请求:它们将直接从应用程序的 static/ 子目录提供服务。

一种可能的解决方法是设置从 staticappname/static 的符号链接。

如果您不想让这样的符号链接弄乱您的存储库,您可以使用 postinstall 脚本来代替:

#!/bin/sh
# This creates the symlink required by DotCloud to serve static content from nginx
ln -s ~/current/appname/static ~/current/static

符号链接很简洁,但是 postinstall 脚本为您提供了机会在文件中添加注释,解释其目的:-)

DotCloud 的未来版本可能会提供“裸配置”切换,其中 nginx 配置不会包含任何特殊的路径处理,以防万一您不想要他们。

同时,如果您想查看 DotCloud 服务的 nginx 默认配置,您只需 dotcloud ssh 到您的服务,然后检查 /etc/nginx/sites-enabled/default

On DotCloud, URLs starting with /static are handled directly by nginx, not by uwsgi. That means that your code will never see those requests: they will be served straight away from the static/ subdirectory of your application.

One possible workaround is to setup a symlink from static to appname/static.

If you don't want to clutter your repository with such a symlink, you can use a postinstall script instead:

#!/bin/sh
# This creates the symlink required by DotCloud to serve static content from nginx
ln -s ~/current/appname/static ~/current/static

The symlink is sleek, but the postinstall scripts gives you the opportunity to drop in a comment in the file, to explain its purpose :-)

Future releases of DotCloud might offer a "naked configuration" toggle, where the nginx configuration won't include any special path handling, just in case you don't want them.

Meanwhile, if you want to see the nginx default configuration of your DotCloud service, you can just dotcloud ssh to your service, and inspect /etc/nginx/sites-enabled/default.

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