English 中文(简体)
是否有办法在环境中或建立时获得构建数字?
原标题:Is there any way to get the build number in the environment or at build-time for a php instance?
  • 时间:2012-05-23 04:37:45
  •  标签:
  • dotcloud

I am trying to get the build number available in the php instance. I will use it as a type of "cache-buster" for the static assets (css, js). Is there any way to get it at run time? If not, is there a way to get it at build time in the postinstall script?

最佳回答

我看到了几种方法 你可以做到这一点。

  1. In /home/dotcloud/ the code directory is a symlink to the build version, so for example my code directory points to git-16ae997. In your postinstall script if you get the name of that directory and store it in a temp file, env variable, or maybe inject it into one of your config scripts, you could reference it from your program.

在您的 < code> postallation 脚本中放置此功能, 将会在您的 < code > 中添加 < code> BUILD_ VERSION 变量。 Profile 中将 < code> < bUILD_ VERSION < / code> 添加到您的 < code > 。 Profession < / code> 中, 您可以从 < code> $ BUILD_ VERSION < /code > 中获取到外壳或其他语言中的 < bUILD_ VERSION < / 。 您可能需要在做出更改后重新源码 < 。 profile 中, 您可能需要在您进行修改以确保它被设置后重新获取 。

$ echo "export BUILD_VERSION=`readlink /home/dotcloud/code`" >> /home/dotcloud/.profile

$ echo $BUILD_VERSION

在 PHP 情况下, 您应该能够使用以下变量在运行时获得它 。

$_ENV["BUILD_VERSION"]
  1. 我在其他项目上使用的另一个方法是在后安装中创建. version 文件, 它仅包含构建的时间戳, 并引用构建_ version 的文件, 并用作您的缓存。 此方法的问题在于它是在 < code> postallom 上创建的, 如果您在 1 例上标, 您最有可能在每种情况下都使用不同的时间戳, 我猜这不是你想要的 。

    日期:%s & gt;/ home/dotcloud/.version

我会坚持1号,因为当你升降时,它会起作用, 并且它更偏向前进。

希望这有帮助。

问题回答

暂无回答




相关问题
Solr Admin not found: "missing core name in path"

I m running solr on dotcloud for my django app (using haystack) and am running into some trouble. I receive a 404 "missing core name in path" message when trying to access the admin, despite the fact ...

Why an extra slash is getting added to urls?

I ve created a blog using django and hosted it on dotcloud http://www.honeybunny.dotcloud.com/blog/ its working fine on the localhost but when i try to access it online an extra slash is added to the ...

Problem with moving static folders

I have a problem with uploading a django app to dotcloud. I m using the code below to change django s admin panel static files to /static/admin_media, but it gives me the following error when ...

howto deploy application on dotcloud

I want to deploy a web.py application on dotcloud. I followed the tutorial, http://docs.dotcloud.com I idd this: $ dotcloud create myapp $ dotcloud push myapp . after a long time waiting,i got this ...

Base path in paster configuration

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 ...

Pushing my code onto DotCloud from cloud9ide.com

I m coding on the cloud9ide, which pushes to github. I then host it on dotcloud. I m trying to see if there s some way I can get my code to deploy onto dotcloud when I push on cloud9ide without doing ...

热门标签