【问题标题】:Unable to restart unicorn无法重启独角兽
【发布时间】:2013-10-21 06:28:58
【问题描述】:

我正在尝试使用命令RUBBER_ENV=staging FILTER=staging cap rubber:unicorn:restart 重新启动独角兽,但出现以下错误:

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 提到的解决方案。但这也不起作用。

有人可以帮忙吗?谢谢

【问题讨论】:

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


    【解决方案1】:

    无论** Auto role: web_tools => staging.x.com, {:platform=>"linux"} 在做什么,它都不是 Capistrano 的一部分。

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

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

    【讨论】:

    • 我做了sudo visudo 并在底部添加了username ALL=(ALL) NOPASSWD: ALL 行,如here 所述。但它没有用。我遇到了同样的错误
    • 如果你所做的工作有效,错误至少会改变,因为 ` * execution "sudo -p 'sudo password: ' bash` 不会再打印了。
    • 我使用sudo su 进行了检查。它不提示输入密码。所以我想我在这里遗漏了其他东西
    • 此时您需要使用更多信息更新您的问题,然后我才能为您提供帮助。当然,set :ssh_options, {:auth_methods => "publickey"}; set :ssh_options, {:keys => ["~/voylla.pem"]} 这两条线可能仍然是问题所在。
    • 我只需将 .pem 文件放在 ~/.ssh 文件夹中并对其执行 ssh-add 即可:)。即使在注释掉两个 set :ssh_options 行之后它也可以工作。
    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 2012-06-01
      • 2023-03-23
      • 2023-03-09
      • 1970-01-01
      • 1970-01-01
      • 2012-01-09
      • 2013-10-21
      • 1970-01-01
      相关资源
      最近更新 更多