Capistrano 生产部署问题

Posted

技术标签:

【中文标题】Capistrano 生产部署问题【英文标题】:Capistrano Production Deploy Issue 【发布时间】:2014-02-03 00:14:45 【问题描述】:

我运行以下命令在 Rackspace 云上准备我的 rails 应用程序并观察到以下错误。

cap production deploy --trace                                                                   ⏎ ✹
** Invoke production (first_time)
** Execute production
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke deploy (first_time)
** Execute deploy
** Invoke deploy:starting (first_time)
** Execute deploy:starting
** Invoke deploy:check (first_time)
** Execute deploy:check
** Invoke git:check (first_time)
** Invoke git:wrapper (first_time)
** Execute git:wrapper
 INFO [4761f9bd] Running /usr/bin/env mkdir -p /tmp/my_app_name/ on example.com
DEBUG [4761f9bd] Command: /usr/bin/env mkdir -p /tmp/my_app_name/
cap aborted!
No route to host - connect(2)
/Users/fr/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.8.0/lib/net/ssh/transport/session.rb:70:in `initialize'
/Users/fr/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.8.0/lib/net/ssh/transport/session.rb:70:in `open'
/Users/fr/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.8.0/lib/net/ssh/transport/session.rb:70:in `block in initialize'
/Users/fr/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/timeout.rb:52:in `timeout'
/Users/fr/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/timeout.rb:97:in `timeout'
/Users/fr/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.8.0/lib/net/ssh/transport/session.rb:67:in `initialize'
/Users/fr/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.8.0/lib/net/ssh.rb:200:in `new'
/Users/fr/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.8.0/lib/net/ssh.rb:200:in `start'
/Users/fr/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.3.0/lib/sshkit/backends/connection_pool.rb:25:in `create_or_reuse_connection'
/Users/fr/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:173:in `ssh'
/Users/fr/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:126:in `block in _execute'
/Users/fr/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:123:in `tap'
/Users/fr/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:123:in `_execute'
/Users/fr/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:66:in `execute'
/Users/fr/.rvm/gems/ruby-2.0.0-p247/gems/capistrano-3.1.0/lib/capistrano/tasks/git.rake:17:in `block (3 levels) in <top (required)>'
/Users/fr/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/Users/fr/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:54:in `run'
/Users/fr/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.3.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
Tasks: TOP => git:check => git:wrapper
The deploy has failed with an error: #<Errno::EHOSTUNREACH: No route to host - connect(2)>
** Invoke deploy:failed (first_time)
** Execute deploy:failed

我尝试查找这些错误所指向的内容,但我很不清楚为什么会显示消息“No route to host”。

【问题讨论】:

【参考方案1】:

在日志输出中,我看到了对example.com 的引用,这可能解释了您得到的No route to host error

您是否像这样在 deploy.rb 中指定了目标服务器的域/IP:

role :web, %wyour_server.com 

如此处所述:http://capistranorb.com/documentation/getting-started/preparing-your-application/

【讨论】:

以上是关于Capistrano 生产部署问题的主要内容,如果未能解决你的问题,请参考以下文章

Capistrano 部署问题

从 GitHub 部署 Key 问题 Capistrano

使用 capistrano 从不同的 git 分支进行部署

使用 pem 文件与 capistrano 一起部署

使用 Capistrano 简化部署

我更改存储库 URL 后 Capistrano 部署失败