我看到了几种方法 你可以做到这一点。
- 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 > 中添加 < code> BUILD_ VERSION code > 变量。 Profile code > 中将 < code> < bUILD_ VERSION < / code> 添加到您的 < code > 。 Profession < / code> 中, 您可以从 < code> $ BUILD_ VERSION < /code > 中获取到外壳或其他语言中的 < bUILD_ VERSION < / 。 您可能需要在做出更改后重新源码 < 。 profile code > 中, 您可能需要在您进行修改以确保它被设置后重新获取 。
$ echo "export BUILD_VERSION=`readlink /home/dotcloud/code`" >> /home/dotcloud/.profile
$ echo $BUILD_VERSION
在 PHP 情况下, 您应该能够使用以下变量在运行时获得它 。
$_ENV["BUILD_VERSION"]
我在其他项目上使用的另一个方法是在后安装中创建. version 文件, 它仅包含构建的时间戳, 并引用构建_ version 的文件, 并用作您的缓存。 此方法的问题在于它是在 < code> postallom code > 上创建的, 如果您在 1 例上标, 您最有可能在每种情况下都使用不同的时间戳, 我猜这不是你想要的 。
日期:%s & gt;/ home/dotcloud/.version
我会坚持1号,因为当你升降时,它会起作用, 并且它更偏向前进。
希望这有帮助。