上限部署的Capistrano-3错误:设置

时间:2014-04-15 10:15:21

标签: ruby-on-rails rubygems capistrano

当我运行cap deploy时,我遇到以下错误:setup。

ayank@vahuradev:~/dev/SandBox$ cap deploy:setup
cap aborted!
wrong number of arguments (5 for 1..2)
/home/mayank/.rvm/gems/ruby-2.1.0/gems/capistrano-3.1.0/lib/capistrano/dsl/env.rb:38:in `server'
config/deploy.rb:16:in `<top (required)>'
/home/mayank/.rvm/gems/ruby-2.1.0/gems/capistrano-3.1.0/lib/capistrano/setup.rb:14:in `load'
/home/mayank/.rvm/gems/ruby-2.1.0/gems/capistrano-3.1.0/lib/capistrano/setup.rb:14:in `block (2 levels) in <top (required)>'
/home/mayank/dev/SandBox/Capfile:26:in `<top (required)>'
/home/mayank/.rvm/gems/ruby-2.1.0/gems/capistrano-3.1.0/lib/capistrano/application.rb:24:in `load_rakefile'
/home/mayank/.rvm/gems/ruby-2.1.0/gems/capistrano-3.1.0/lib/capistrano/application.rb:15:in `run'
/home/mayank/.rvm/gems/ruby-2.1.0/gems/capistrano-3.1.0/bin/cap:3:in `<top (required)>'
/home/mayank/.rvm/gems/ruby-2.1.0/bin/cap:23:in `load'
/home/mayank/.rvm/gems/ruby-2.1.0/bin/cap:23:in `<main>'
/home/mayank/.rvm/gems/ruby-2.1.0/bin/ruby_executable_hooks:15:in `eval'
/home/mayank/.rvm/gems/ruby-2.1.0/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => production
(See full trace by running task with --trace)

我的 deploy.rb 文件如下:

#require 'bundler/capistrano'

set :application, "SandBox"
set :repository,  "repo address" => this is correct
set :deploy_to, "/home/vahuadmin/SandBox"
set :scm, :git
set :branch, "master"
set :user, "mayank "
set :group, "deployers"
set :use_sudo, false
set :rails_env, "production"
set :deploy_via, :copy
set :ssh_options, { :forward_agent => true, :port => 4321 }
set :keep_releases, 5
default_run_options[:pty] = true
server "xxx.xx.xx.xx", :app, :web, :db, :primary => true
server "xxx.xx.xx.xx", roles: [:app, :web, :db], :primary => true
namespace :deploy do
  task :start do ; end
  task :stop do ; end

  desc "Symlink shared config files"
  task :symlink_config_files do
    run "#{ sudo } ln -s #{ deploy_to }/shared/config/database.yml #{ current_path }/config/database.yml"
  end

  # NOTE: I don't use this anymore, but this is how I used to do it.
  desc "Precompile assets after deploy"
  task :precompile_assets do
    run <<-CMD
      cd #{ current_path } &&
      #{ sudo } bundle exec rake assets:precompile RAILS_ENV=#{ rails_env }
    CMD
  end

  desc "Restart applicaiton"
  task :restart do
    run "#{ try_sudo } touch #{ File.join(current_path, 'tmp', 'restart.txt') }"
  end
end

after "deploy", "deploy:symlink_config_files"
after "deploy", "deploy:restart"
after "deploy", "deploy:cleanup"

包含的gem&gt;&gt;&gt;

gem 'capistrano', '~> 3.1.0'

# rails specific capistrano funcitons
gem 'capistrano-rails', '~> 1.1.0'

# integrate bundler with capistrano
gem 'capistrano-bundler'

# if you are using RBENV
gem 'capistrano-rbenv', "~> 2.0"

知道为什么会出现这个错误以及如何解决这个问题。请帮助!!

1 个答案:

答案 0 :(得分:4)

server "xxx.xx.xx.xx", :app, :web, :db, :primary => true应为

server "xxx.xx.xx.xx", :roles => [:app, :web, :db], :primary => true

你传递5个参数,它只允许1或2;服务器名称和可选的选项哈希值。