作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有这个任务:
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
像我说的那样进入发布目录?
最佳答案
另一个答案中有有用的信息 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/
我有这个任务: namespace :custom do desc "create a symlink to db config already on the server" task :sy
我对 Capistrano 3.2.1 版有疑问。在我的 deploy.rb 文件中,我使用了以下行: set :theme_path, "#{release_path}/web/app/themes
current_path 之间有什么区别?和 release_path Capistrano 中的路径变量,如 task :path do on roles :app do p
我是一名优秀的程序员,十分优秀!