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:in
block 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:in
load_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
eval'
/home/hadoop/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in
'
(See full trace by running task with --trace)
求助,哪里错了?