【问题标题】:Capistrano-3 error on cap deploy:setupCap部署时出现Capistrano-3错误:设置
【发布时间】:2014-04-15 10:15:21
【问题描述】:

运行 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 '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"

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

【问题讨论】:

    标签: ruby-on-rails rubygems capistrano


    【解决方案1】:

    server "xxx.xx.xx.xx", :app, :web, :db, :primary =&gt; true 应该是

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-22
      • 2011-02-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多