我正在学习一个不错的教程 here,它确实帮助我解决了一些问题。 Rails apache 和 rvm 都可以很好地协同工作。我快完成了,但在最后一部分卡住了。

基本上,我的部署文件与他所拥有的类似,但似乎无法调试他正在寻找的内容。 deploy.rb 文件如下所示:

#RVM Bootstrap
$:.unshift(File.expand_path('./lib',ENV['rvm_path']))

require 'rvm/capistrano'
set :rvm_ruby_string, '1.9.2-p318'


#bundler bootstrap
require 'bundler/capistrano'

#main details
set :application , "test"
role :web, "test"
role :app, "test"
role :db, "test", :primary => true

#server Details
default_run_options[:pty] = true
ssh_options[:forward_agent] = true
set :deploy_to, "/var/www/test/"
set :deploy_via, :remote_cache
set :user, "passenger"
set :use_sudo, false


# repo details
set :scm, :git
set :scm_username, "passenger"
set :repository, "git@gitserver:test.git"
set :branch, "master"
set :git_enable_submodules, 1

# tasks
namespace :deploy do
  task :start, :roles => :app do
    run "touch #{current_path}/tmp/restart.txt"
  end

  task :stop, :roles => :app do
    # Do nothing.
  end
  desc "Restart Application"
  task :restart, :roles => :app do
    run "touch #{current_path}/tmp/restart.txt"
  end
end

当我尝试使用 capistrano 和 cap deploy:setup 部署应用程序时
我收到以下错误:
  * executing `deploy:setup'
  * executing "mkdir -p /var/www/test/ /var/www/test/releases /var/www/test/shared /var/www/test/shared/system /var/www/test/shared/log /var/www/test/shared/pids"
    servers: ["test"]
connection failed for: test (SocketError: getaddrinfo: Name or service not known)

我稍微修改了一下。 Rails webrick 启动 rails 应用程序没有问题,所以它一定与我部署到 apache 有关系。需要注意的一点是应用名称“app”(因为在rails中test是保留的),域名是“test”。

这种不匹配可能会导致问题,但我几乎没有经验,所以我不确定。

谁能指出我在哪里调试或它可能是什么?

最佳答案

角色 web、app 和 db 需要是您要部署到的服务器的 URL 或 IP。像这样的东西:

task :staging do
  set :rails_env, 'staging'
  role :app, "example.com"
  role :web, "example.com"
  role :db,  "example.com", :primary => true
end

关于ruby-on-rails - capistrano 的部署问题,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9659592/

10-16 18:21