Capistrano连接问题

时间:2013-07-06 06:58:48

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

我正在尝试在我的rails项目目录中运行cap deploy:setup,我收到此错误。

* 2013-07-06 02:46:14 executing `deploy:setup'
* executing multiple commands in parallel


-> "else" :: "sudo -p 'sudo password: ' mkdir -p /var/www /var/www/releases /var/www/shared /var/www/shared/system /var/www/shared/log /var/www/shared/pids"
    -> "else" :: "sudo -p 'sudo password: ' mkdir -p /var/www /var/www/releases /var/www/shared /var/www/shared/system /var/www/shared/log /var/www/shared/pids"
    -> "else" :: "sudo -p 'sudo password: ' mkdir -p /var/www /var/www/releases /var/www/shared /var/www/shared/system /var/www/shared/log /var/www/shared/pids"
    -> "else" :: "sudo -p 'sudo password: ' mkdir -p /var/www /var/www/releases /var/www/shared /var/www/shared/system /var/www/shared/log /var/www/shared/pids"
    -> "else" :: "sudo -p 'sudo password: ' mkdir -p /var/www /var/www/releases /var/www/shared /var/www/shared/system /var/www/shared/log /var/www/shared/pids"
    servers: ["your web-server here", "*web-address-from-capfile*", "your app-server here", "your primary db-server here", "your slave db-server here"]
connection failed for: your primary db-server here (SocketError: getaddrinfo: nodename nor servname provided, or not known), your web-server here (SocketError: getaddrinfo: nodename nor servname provided, or not known), your slave db-server here (SocketError: getaddrinfo: nodename nor servname provided, or not known), your app-server here (SocketError: getaddrinfo: nodename nor servname provided, or not known)

我的Capfile是这样的:

load 'deploy'
# Uncomment if you are using Rails' asset pipeline
load 'deploy/assets'
load 'config/deploy' # remove this line to skip loading any of the default tasks



set :application, "myapp"

set :repository, "file://~/git/#{application}.git"
set :local_repository, "myserver:~/git/#{application}.git"
set :branch, "master"

set :scm, :git


set :deploy_to, "/var/www"

ssh_options[:forward_agent] = true
default_run_options[:pty] = true


set :user, "me"
ssh_options[:keys] = %w(~/.ssh/id_rsa)

set :port, 33333


server "example.com", :app, :web, :db, :primary => true

这个错误真的让我抓狂。应该注意的是,我能够使用我的公钥/私钥ssh到我的服务器,sshd设置为侦听远程主机上的非默认端口(因此set :port行)。

1 个答案:

答案 0 :(得分:0)

所以这是一个愚蠢的错误......我在rails项目目录中编辑Capfile而不是config/deploy.rb。我在这个链接https://github.com/capistrano/capistrano/wiki/2.x-From-The-Beginning上关注的教程非常清楚地说明要编辑config/deploy.rb,但因为我已经习惯了Makefile,所以我不假思索地直接进入Capfile。

正如您在config/deploy.rb中注意到的那样,这些默认行存在。

role :web, "your web-server here"                          # Your HTTP server, Apache/etc
role :app, "your app-server here"                          # This may be the same as your `Web` server
role :db,  "your primary db-server here", :primary => true # This is where Rails migrations will run
role :db,  "your slave db-server here"

这是导致发布问题的原因,因为“您的Web服务器”当然不是可连接的服务器。