Capistrano rvmsudo

时间:2011-11-13 03:25:19

标签: ruby-on-rails ruby-on-rails-3 rvm capistrano sudo

Capistrano不能与我的deploy.rb中的rvmsudo一起使用。

我试过

set :sudo, 'rvmsudo'
set :sudo_prompt, 'password: '

然后使用以下命令运行命令:

sudo "god -c config/unicorn.god --log-level debug"

但Capistrano卡在密码提示上。

此解决方案here表示使用sudo "whoami"然后使用rvmsudo,因为它会记住您的密码5分钟,但我的密码不会被记住。

上下文

desc "Start unicorn"
  task :start, :except => { :no_release => true } do
  sudo "god -c config/unicorn.god --log-level debug"
end

3 个答案:

答案 0 :(得分:3)

你在做什么

require 'bundler/capistrano'

它的hacky,但你可以尝试:

after "deploy:update_code", :do_bundle_install

task :do_bundle_install do
  run "cd #{current_release} && rvmsudo bundle install --gemfile #{current_release}/Gemfile --path {path to install}/bundle --without development test cucumber"
end

答案 1 :(得分:3)

尝试使用它:

task :do_something do
    run "cd #{latest_release} && rvmsudo -p '#{sudo_prompt}' some_command"
end

它对我有用!

答案 2 :(得分:1)

尝试在run命令中使用sudo,但是从set中调用sudo:

task :do_something do
  run "#{sudo} root task"
end

这样一来,如果你改变主意,就不需要重写所有任务,只需删除set :sudo