【发布时间】:2013-02-28 20:14:17
【问题描述】:
deploy:setup 和使用 Capistrano 进行冷部署的正确方法是什么?
使用
- this
deploy.rb - Capistrano v2.14.2
- Vagrant 虚拟化我的服务器,
这是我的场景:
-
在运行
deploy:setup时,Capistrano 使用 root 权限来准备目录结构以进行部署:$ cap deploy:setup * 2013-02-28 14:50:21 executing `deploy:setup' * executing "sudo -p 'sudo password: ' mkdir -p /home/vagrant/example /home/vagrant/example/releases /home/vagrant/example/shared /home/vagrant/example/shared/system /home/vagrant/example/shared/log /home/vagrant/example/shared/pids" servers: ["example.com"] [example.com] executing command command finished in 29ms * executing "sudo -p 'sudo password: ' chmod g+w /home/vagrant/example /home/vagrant/example/releases /home/vagrant/example/shared /home/vagrant/example/shared/system /home/vagrant/example/shared/log /home/vagrant/example/shared/pids" servers: ["example.com"] [example.com] executing command command finished in 11ms -
然而在
deploy:coldCapistrano 尝试结帐(在这种情况下从 git)并以vagrant用户的身份写入 - 在deploy.rb中指定的用户:$ cap deploy:cold * 2013-02-28 14:50:47 executing `deploy:cold' * 2013-02-28 14:50:47 executing `deploy:update' ** transaction: start * 2013-02-28 14:50:47 executing `deploy:update_code' updating the cached checkout on all servers executing locally: "git ls-remote git@github.com:mariusbutuc/realtime-faye.git master" command finished in 2360ms * executing "if [ -d /home/vagrant/example/shared/cached-copy ]; then cd /home/vagrant/example/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard a7c05516bc31c2c18f89057c02f84bfad83a6b59 && git clean -q -d -x -f; else git clone -q git@github.com:mariusbutuc/realtime-faye.git /home/vagrant/example/shared/cached-copy && cd /home/vagrant/example/shared/cached-copy && git checkout -q -b deploy a7c05516bc31c2c18f89057c02f84bfad83a6b59; fi" servers: ["example.com"] [example.com] executing command ** [example.com :: out] fatal: could not create work tree dir '/home/vagrant/example/shared/cached-copy'.: Permission denied command finished in 26ms *** [deploy:update_code] rolling back * executing "rm -rf /home/vagrant/example/releases/20130228195049; true" servers: ["example.com"] [example.com] executing command command finished in 7ms failed: "sh -c 'if [ -d /home/vagrant/example/shared/cached-copy ]; then cd /home/vagrant/example/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard a7c05516bc31c2c18f89057c02f84bfad83a6b59 && git clean -q -d -x -f; else git clone -q git@github.com:mariusbutuc/realtime-faye.git /home/vagrant/example/shared/cached-copy && cd /home/vagrant/example/shared/cached-copy && git checkout -q -b deploy a7c05516bc31c2c18f89057c02f84bfad83a6b59; fi'" on example.com -
当然,
deploy:check报告并不令人意外:vagrant用户无法写入在deploy:setup期间创建的目录,因为这两个用户属于不同的组 -root:root与vagrant:vagrant:$ cap deploy:check [...] The following dependencies failed. Please check them and try again: --> You do not have permissions to write to `/home/vagrant/example'. (example.com) --> You do not have permissions to write to `/home/vagrant/example/releases'. (example.com) --> `/home/vagrant/example/shared' is not writable (example.com)
这背后的原因是什么,什么先决条件还没有满足,所以部署通过了这个问题?
【问题讨论】:
-
您不想手动更改权限?
-
我遇到了完全相同的问题...我不明白为什么这些目录是作为 root 用户而不是
deploy.rb文件中指定的用户创建的。我假设这是一个错误?我最终只是通过 SSH 登录并手动更改权限。
标签: ruby-on-rails ruby deployment capistrano