我有下面的厨师食谱:
deploy "/home/prj" do
repo "https://path_to_repo"
user node.project_owner
group node.project_owner
symlink_before_migrate({})
end如何访问提供者的发布路径?在我的例子中,将是:/home/prj/release/20120506125222/。
发布于 2012-05-08 19:26:02
这取决于您想要访问发布路径的位置。在“内部”的资源,即回调,这是很容易成为可能使用类似的东西
deploy "/home/prj" do
before_migrate do
gemfile = File.read("#{release_path}/Gemfile")
end
end在资源之外,您没有可用的release_path变量。但是,您可以使用current符号链接,它指向当前部署的版本,即最新版本:
current_path = "home/prj/current"
release_path = File.readlink(current_path)大多数情况下,您可以直接访问current_path中的内容,而不必求助于解析符号链接目标。
也就是说,你通常不想在那里直接做事情。相反,鼓励您在共享目录(即/home/prk/shared)中生成额外的文件,并让chef在部署期间将这些文件符号链接到发行版中。这正是symlink_before_migrate的作用所在。这样,你实际上不需要自己知道发布路径,但可以让chef为你处理。
https://stackoverflow.com/questions/10496782
复制相似问题