2011-10-25 23:30:39 +01:00
|
|
|
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
|
2011-03-28 16:49:22 +01:00
|
|
|
require 'rvm/capistrano'
|
2011-10-25 23:30:39 +01:00
|
|
|
require 'bundler/capistrano'
|
|
|
|
require 'airbrake/capistrano'
|
|
|
|
|
2011-10-31 17:50:45 +00:00
|
|
|
set :whenever_command, "bundle exec whenever"
|
|
|
|
require "whenever/capistrano"
|
|
|
|
|
2011-03-28 16:49:22 +01:00
|
|
|
set :rvm_type, :user
|
|
|
|
|
2011-11-09 20:15:02 +00:00
|
|
|
set :default_stage, "staging"
|
|
|
|
set :stages, %w(production staging)
|
|
|
|
require 'capistrano/ext/multistage'
|
|
|
|
|
2011-03-28 16:49:22 +01:00
|
|
|
# bundler bootstrap
|
|
|
|
|
|
|
|
# main details
|
2011-09-29 14:24:33 +01:00
|
|
|
ssh_options[:forward_agent] = true
|
2011-10-25 23:30:39 +01:00
|
|
|
|
2011-03-28 16:49:22 +01:00
|
|
|
set :application, "rosa_build"
|
|
|
|
|
2011-10-25 23:30:39 +01:00
|
|
|
set :repository, "git@github.com:warpc/rosa-build.git"
|
|
|
|
# set :git_shallow_clone, 1
|
2011-03-28 16:49:22 +01:00
|
|
|
set :scm, "git"
|
|
|
|
|
2011-10-25 23:30:39 +01:00
|
|
|
set :user, "rosa"
|
|
|
|
set :use_sudo, false
|
|
|
|
set :deploy_to, "/srv/#{application}"
|
2011-11-18 12:50:06 +00:00
|
|
|
# set :deploy_via, :copy
|
|
|
|
# set :copy_cache, true
|
2011-03-28 16:49:22 +01:00
|
|
|
|
|
|
|
set :keep_releases, 3
|
|
|
|
|
|
|
|
task :symlink_config_files do
|
|
|
|
run "mkdir -p #{deploy_to}/#{shared_dir}/config"
|
|
|
|
|
2011-04-13 16:41:41 +01:00
|
|
|
run "yes y | cp -i #{release_path}/config/database.yml.sample #{deploy_to}/#{shared_dir}/config/database.yml"
|
|
|
|
run "yes y | cp -i #{release_path}/config/application.yml.sample #{deploy_to}/#{shared_dir}/config/application.yml"
|
2011-03-28 17:31:29 +01:00
|
|
|
|
2011-03-28 16:49:22 +01:00
|
|
|
|
2011-10-25 23:30:39 +01:00
|
|
|
run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
|
|
|
|
run "ln -nfs #{shared_path}/config/application.yml #{release_path}/config/application.yml"
|
2011-03-28 16:49:22 +01:00
|
|
|
end
|
|
|
|
|
2011-10-31 10:49:11 +00:00
|
|
|
task :symlink_downloads_dir do
|
|
|
|
run "ln -nfs #{shared_path}/downloads/ #{release_path}/public/downloads"
|
|
|
|
end
|
|
|
|
|
2011-10-29 22:21:49 +01:00
|
|
|
task :generate_roles do
|
|
|
|
run "cd #{deploy_to}/current ; RAILS_ENV=production bundle exec rake rights:generate"
|
2011-10-30 13:17:52 +00:00
|
|
|
#run "cd #{deploy_to}/current ; RAILS_ENV=production bundle exec rake roles:load"
|
2011-10-29 22:21:49 +01:00
|
|
|
run "cd #{deploy_to}/current ; RAILS_ENV=production bundle exec rake roles:apply"
|
|
|
|
end
|
|
|
|
|
2011-03-28 16:49:22 +01:00
|
|
|
namespace :deploy do
|
|
|
|
task :restart, :roles => :app, :except => { :no_release => true } do
|
2011-10-30 19:32:13 +00:00
|
|
|
run "touch #{current_release}/tmp/restart.txt"
|
2011-04-11 18:07:49 +01:00
|
|
|
restart_dj
|
2011-03-28 16:49:22 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
%w(start).each { |name| task name, :roles => :app do deploy.restart end }
|
2011-03-29 15:58:20 +01:00
|
|
|
|
2011-04-11 17:51:54 +01:00
|
|
|
desc "Restart delayed job"
|
|
|
|
task :restart_dj, :roles => :web do
|
|
|
|
run "cd #{deploy_to}/current ; RAILS_ENV=production ./script/delayed_job stop; RAILS_ENV=production ./script/delayed_job start; true"
|
|
|
|
end
|
|
|
|
|
2011-03-29 17:35:42 +01:00
|
|
|
after "deploy:update_code", :roles => :web do
|
2011-03-29 18:06:21 +01:00
|
|
|
symlink_config_files
|
2011-10-31 10:51:22 +00:00
|
|
|
symlink_downloads_dir
|
2011-11-21 13:33:27 +00:00
|
|
|
# generate_roles
|
2011-03-29 17:35:42 +01:00
|
|
|
end
|
2011-03-29 18:06:21 +01:00
|
|
|
end
|