粗体的几行加上就好了。
deploy.rb:
coding: utf-8
require 'bundler/capistrano'
** require 'rvm/capistrano' **
set :application, "aaa"
set :repository, "https://aaa:[email protected]:8443/git/web.git"
set :branch, "single"
set :scm, :git
set :user, "deployer"
set :deploy_to, "/home/#{user}/#{application}"
#set :deploy_via, :remote_cache
set :use_sudo, false
** default_run_options[:pty] = true **
** set :rvm_ruby_string, 'ruby-1.9.3-p448@global' **
** set :rvm_type, :system **
role :web, "192.168.5.100"
role :app, "192.168.5.100"
role :db, "192.168.5.100", :primary => true
unicorn.rb 路径
set :unicorn_path, "#{deploy_to}/current/config/unicorn.rb"
set :unicorn_pid, "#{deploy_to}/current/tmp/pids/unicorn.pid"
namespace :deploy do
task :start, :roles => :app do
run "cd #{deploy_to}/current/; bundle exec unicorn_rails -c #{unicorn_path} -E production -D"
end
task :stop, :roles => :app do
run "kill -QUIT cat #{deploy_to}/current/tmp/pids/unicorn.pid
"
end
desc "Restart Application"
task :restart, :roles => :app do
run "if [ -f #{unicorn_pid} ] && [ -e /proc/$(cat #{unicorn_pid}) ]; then kill -QUIT cat #{unicorn_pid}
; fi"
run "cd #{deploy_to}/current && bundle exec unicorn_rails -c #{unicorn_path} -E production -D"
end
task :assets, :roles => :app do
run "cd #{deploy_to}/current; RAILS_ENV=production bundle exec rake assets:precompile"
end
end
task :init_shared_path, :roles => :web do
run "mkdir -p #{deploy_to}/shared/report"
end
task :link_shared_files, :roles => :web do
run "ln -sf #{deploy_to}/shared/report #{deploy_to}/current/public/"
end
after 'deploy:update', 'deploy:migrate'
after 'deploy:update', 'deploy:assets'