0

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

* 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行)。

4

1 回答 1

0

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

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

于 2013-07-06T14:13:32.250 回答