无法重启独角兽

时间:2013-10-21 06:28:59

标签: ruby-on-rails ruby amazon-ec2 capistrano

我正在尝试使用命令RUBBER_ENV=staging FILTER=staging cap rubber:unicorn:restart重启unicorn,但我收到以下错误:

triggering load callbacks
* 2013-10-21 11:49:47 executing `rubber:init'
** Auto role: app => staging.x.com, {:platform=>"linux"}
** Auto role: unicorn => staging.x.com, {:platform=>"linux"}
** Auto role: nginx => staging.x.com, {:platform=>"linux"}
** Auto role: collectd => staging.x.com, {:platform=>"linux"}
** Auto role: common => staging.x.com, {:platform=>"linux"}
** Auto role: monit => staging.x.com, {:platform=>"linux"}
** Auto role: db => staging.x.com, {:primary=>true, :platform=>"linux"}
** Auto role: postgresql => staging.x.com, {:platform=>"linux"}
** Auto role: postgresql_master => staging.x.com, {:platform=>"linux"}
** Auto role: examples => staging.x.com, {:platform=>"linux"}
** Auto role: graphite_server => staging.x.com, {:platform=>"linux"}
** Auto role: graphite_web => staging.x.com, {:platform=>"linux"}
** Auto role: memcached => staging.x.com, {:platform=>"linux"}
** Auto role: web => staging.x.com, {:platform=>"linux"}
** Auto role: web_tools => staging.x.com, {:platform=>"linux"}
 * 2013-10-21 11:49:50 executing `rubber:unicorn:restart'
 * 2013-10-21 11:49:50 executing `rubber:unicorn:stop'
 * executing "sudo -p 'sudo password: '  bash -l -c 'if [ -f /var/run/unicorn.pid ]; then pid=`cat /var/run/unicorn.pid` && kill -TERM $pid; fi'"
servers: ["staging.voylla.com"]
connection failed for: staging.x.com (Net::SSH::AuthenticationFailed: root)

有些research提出了一些问题,但即使我的deploy.rb中设置了以下内容,我也会收到错误:

set :ssh_options, {:auth_methods => "publickey"}
set :ssh_options, {:keys => ["~/voylla.pem"]}

我甚至尝试了here提到的解决方案。但这也不起作用。

请有人帮忙。感谢

2 个答案:

答案 0 :(得分:0)

无论** Auto role: web_tools => staging.x.com, {:platform=>"linux"}做什么,它都不属于Capistrano。

问题是sudo无法在没有密码的情况下更改为您的超级用户帐户,因此系统会提示您。在Capistrano 2.x中你可以看到提示,但是没有办法回答它(因为输入处理的工作原理很奇怪,你输入的任何东西都是无处发送的)

我建议的解决方法是确保您的部署用户无需密码即可调用sudo,或更改您的脚本,以便您可以调用的setuid脚本封装此逻辑。< / p>

答案 1 :(得分:0)

将.pem文件添加到~/.ssh文件夹,然后在.pem文件上执行ssh-add