Capistrano部署失败 - 连接由远程主机关闭 - 任务:TOP => rbenv:验证

时间:2015-05-13 02:02:38

标签: ruby-on-rails ruby ssh capistrano rbenv

Capistrano未能部署我的Ruby on Rails应用程序。自从我之前成功部署以来,我没有更改任何配置文件(Capfile,deploy.rb等)。

chris-iMac:untrackedlatest Chris$ cap production deploy --trace
** Invoke production (first_time)
** Execute production
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke bundler:map_bins (first_time)
** Execute bundler:map_bins
** Invoke deploy:set_rails_env (first_time)
** Execute deploy:set_rails_env
** Invoke deploy:set_rails_env 
** Invoke rbenv:validate (first_time)
** Execute rbenv:validate
DEBUG [eb8ce4ac] Running /usr/bin/env [ -d /usr/local/rbenv/versions/2.1.5 ] as deploy@XXX.XXX.XXX.XXX
DEBUG [eb8ce4ac] Command: [ -d /usr/local/rbenv/versions/2.1.5 ]
Text will be echoed in the clear. Please install the HighLine or Termios libraries to suppress echoed text.
deploy@XXX.XXX.XXX.XXX's password:XXXX
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deploy@XXX.XXX.XXX.XXX: connection closed by remote host
/Users/Chris/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/runners/parallel.rb:16:in `rescue in block (2 levels) in execute'
/Users/Chris/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
Net::SSH::Disconnect: connection closed by remote host
/Users/Chris/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.2/lib/net/ssh/transport/packet_stream.rb:105:in `block in next_packet'
/Users/Chris/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.2/lib/net/ssh/transport/packet_stream.rb:95:in `loop'
/Users/Chris/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.2/lib/net/ssh/transport/packet_stream.rb:95:in `next_packet'
/Users/Chris/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.2/lib/net/ssh/transport/session.rb:183:in `block in poll_message'
/Users/Chris/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.2/lib/net/ssh/transport/session.rb:178:in `loop'
/Users/Chris/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.2/lib/net/ssh/transport/session.rb:178:in `poll_message'
/Users/Chris/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.2/lib/net/ssh/transport/session.rb:163:in `next_message'
/Users/Chris/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/session.rb:95:in `block in next_message'
/Users/Chris/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/session.rb:94:in `loop'
/Users/Chris/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/session.rb:94:in `next_message'
/Users/Chris/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/methods/password.rb:25:in `authenticate'
/Users/Chris/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/session.rb:79:in `block in authenticate'
/Users/Chris/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/session.rb:66:in `each'
/Users/Chris/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/session.rb:66:in `authenticate'
/Users/Chris/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.2/lib/net/ssh.rb:211:in `start'
/Users/Chris/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/backends/connection_pool.rb:50:in `call'
/Users/Chris/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/backends/connection_pool.rb:50:in `create_new_entry'
/Users/Chris/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/backends/connection_pool.rb:22:in `checkout'
/Users/Chris/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.rb:187:in `with_ssh'
/Users/Chris/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.rb:137:in `block in _execute'
/Users/Chris/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.rb:133:in `tap'
/Users/Chris/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.rb:133:in `_execute'
/Users/Chris/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.rb:62:in `test'
/Users/Chris/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/capistrano-rbenv-2.0.3/lib/capistrano/tasks/rbenv.rake:10:in `block (3 levels) in <top (required)>'
/Users/Chris/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/Users/Chris/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.rb:54:in `run'
/Users/Chris/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/runners/parallel.rb:13:in `block (2 levels) in execute'
Tasks: TOP => rbenv:validate

本地红宝石版本:

chris-iMac:untrackedlatest Chris$ ruby -v
ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-darwin14.0]

远程ruby版本:

untracked@untrackedprod:/srv/untracked/current$ ruby -v
ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-linux]

自上次成功部署以来,我没有对ClientAliveInterval / ServerAliveInterval进行任何改动。

我能够成功SSH到服务器。

Capistrano宝石:

Using capistrano 3.4.0
Using capistrano-bundler 1.1.4
Using capistrano-passenger 0.0.5
Using capistrano-rails 1.1.3
Using capistrano-rbenv 2.0.3

服务器正在运行Ubuntu 14.04

非常感谢任何帮助!

2 个答案:

答案 0 :(得分:0)

我遇到了同样的问题。我通过两个步骤解决了这个问题:

  1. 我只需在服务器文件~/.ssh/authorized_keys中添加一行,内容就是我的本地文件~/.ssh/id_rsa.pub
  2. 由于我的mac和VirtualBox VM上有两个相同的帐户名,而我在服务器文件~/.ssh/authorized_keys中取消注释其中一个,所以一切顺利。
  3. 祝你好运!

答案 1 :(得分:0)

它可能不是正确的解决方案,但对于我从新标签/终端开始部署工作。我认为需要重新启动shell。