部署 cap 报错【NoMethodError: undefined method `map' for :roles:Symbol】

string2020 · September 06, 2014 · Last by ericguo replied at September 06, 2014 · 3580 hits

Capfile 内容: require 'capistrano/setup' require 'capistrano/deploy' Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }

config/deploy.rb 内容: lock '3.2.1' set :application, 'taobao' set :repo_url, '[email protected]:string2020/shop.git' set :stages, %w(production staging) set :default_stage, "production" set :deploy_to, '/home/hadoop/my_app' set :scm, :git set :pty, true set :default_env, { path: "$PATH" } set :use_sudo, true set :pid_path, '/tmp/jshop_unicorn.pid'

namespace :deploy do task :start, :roles => :app do run "cd #{deploy_to}/current/; RAILS_ENV=#{stage} bundle exec unicorn_rails -c #{unicorn_path} -D" end

task :stop, :roles => :app do run "kill -QUIT cat #{pid_path}" end

desc "Reload Application" task :reload, :roles => :app do run "kill -USR2 cat #{pid_path}" end

desc "Restart Application" task :restart, :roles => :app do run "kill -QUIT cat #{pid_path}" run "cd #{deploy_to}/current/; RAILS_ENV=#{stage} bundle exec unicorn_rails -c #{unicorn_path} -D" end end

config/deploy/production.rb 内容为: set :port, '22'

set :ipaddr do default_ips = '223' ipaddr = Capistrano::CLI.ui.ask "ip address to deploy: [#{default_ips}] " ipaddr = default_ips if ipaddr.empty? ipaddr = "192.168.1.#{ipaddr}" ipaddr end

role :app, "#{ipaddr}" role :web, "#{ipaddr}"

最后,执行 hadoop@rubypc:~/src/jshop$ cap -vT cap aborted! NoMethodError: undefined method map' for :roles:Symbol /home/hadoop/src/jshop/config/deploy.rb:47:inblock in ' /home/hadoop/src/jshop/config/deploy.rb:46:in <top (required)>' /home/hadoop/.rvm/gems/ruby-2.1.2/gems/capistrano-3.2.1/lib/capistrano/application.rb:48:inload_imports' /home/hadoop/.rvm/gems/ruby-2.1.2/gems/capistrano-3.2.1/lib/capistrano/application.rb:15:in run' /home/hadoop/.rvm/gems/ruby-2.1.2/gems/capistrano-3.2.1/bin/cap:3:in' /home/hadoop/.rvm/gems/ruby-2.1.2/bin/cap:23:in load' /home/hadoop/.rvm/gems/ruby-2.1.2/bin/cap:23:in' /home/hadoop/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in eval' /home/hadoop/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in' (See full trace by running task with --trace)

求助,哪里错了?

deploy.rb 一般应该是这样的语法吧?

namespace :deploy do

  desc 'Restart application'
  task :restart do
    on roles(:app), in: :sequence, wait: 5 do
      # Your restart mechanism here, for example:
      execute :touch, release_path.join('tmp/restart.txt')
      execute :curl, '-s -D - apc.sandisk.com -o /dev/null'
    end
  end

  after :publishing, :restart

  after :restart, :clear_cache do
    on roles(:web), in: :groups, limit: 3, wait: 10 do
      # Here we can do anything such as:
      # within release_path do
      #   execute :rake, 'cache:clear'
      # end
    end
  end

end
You need to Sign in before reply, if you don't have an account, please Sign up first.