gpt4 book ai didi

Capistrano 不服从 "within release_path"

转载 作者:行者123 更新时间:2023-12-04 23:21:12 24 4
gpt4 key购买 nike

我有这个任务:

namespace :custom do
desc "create a symlink to db config already on the server"
task :symlink_db_config do
on roles(:web) do
within release_path do
execute "pwd"
end

within release_path do
execute "ln -nfs /home/blog/config/database.yml ./database.yml"
end
end
end
end

出于某些令人气愤的原因,pwd命令前面是 cd到发布路径,但 ln命令不是。这是为什么?

这是输出,显示了上面的内容:
** Invoke custom:symlink_db_config (first_time)
** Execute custom:symlink_db_config
DEBUG[352cc4bb] Running /usr/bin/env if test ! -d /home/blog/staging/releases/20141010050707; then echo "Directory does not exist '/home/blog/staging/releases/20141010050707'" 1>&2; false; fi on 172.245.32.193
DEBUG[352cc4bb] Command: if test ! -d /home/blog/staging/releases/20141010050707; then echo "Directory does not exist '/home/blog/staging/releases/20141010050707'" 1>&2; false; fi
DEBUG[352cc4bb] Finished in 0.199 seconds with exit status 0 (successful).

// Here's the `pwd`; note the proper `cd` that occurs first:

INFO[67a83a04] Running /usr/bin/env pwd on 172.245.32.193
DEBUG[67a83a04] Command: cd /home/blog/staging/releases/20141010050707 && /usr/bin/env pwd
DEBUG[67a83a04] /home/blog/staging/releases/20141010050707
INFO[67a83a04] Finished in 0.268 seconds with exit status 0 (successful).
DEBUG[f46f64b3] Running /usr/bin/env if test ! -d /home/blog/staging/releases/20141010050707; then echo "Directory does not exist '/home/blog/staging/releases/20141010050707'" 1>&2; false; fi on 172.245.32.193
DEBUG[f46f64b3] Command: if test ! -d /home/blog/staging/releases/20141010050707; then echo "Directory does not exist '/home/blog/staging/releases/20141010050707'" 1>&2; false; fi
DEBUG[f46f64b3] Finished in 0.243 seconds with exit status 0 (successful).

//And now here's the `ln`... but where is the `cd`? I said `within release_path`, didn't I?

INFO[afdbd89c] Running /usr/bin/env ln -nfs /home/blog/config/database.yml ./database.yml on 172.245.32.193
DEBUG[afdbd89c] Command: ln -nfs /home/blog/config/database.yml ./database.yml
INFO[afdbd89c] Finished in 0.219 seconds with exit status 0 (successful).

所以我的 ln失败,因为它不在正确的目录中。为什么没有 capistrano cd像我说的那样进入发布目录?

(顺便说一下,Capistrano 3.2.1)

最佳答案

另一个答案中有有用的信息 here但简而言之,当您要运行的命令中有空格时,似乎会出现问题。

我遵循了砖家的建议,例如

within release_path do
execute *%w[ ln -nfs /home/blog/config/database.yml ./database.yml ]
end

关于Capistrano 不服从 "within release_path",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26292351/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com