rosa-build/config/deploy.rb

84 lines
2.5 KiB
Ruby
Raw Normal View History

2011-10-25 23:30:39 +01:00
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
require 'rvm/capistrano'
2011-10-25 23:30:39 +01:00
require 'bundler/capistrano'
require 'airbrake/capistrano'
set :rvm_type, :user
# 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
set :application, "rosa_build"
2011-10-25 23:30:39 +01:00
set :repository, "git@github.com:warpc/rosa-build.git"
set :branch, "master"
# set :git_shallow_clone, 1
set :scm, "git"
2011-10-25 23:30:39 +01:00
set :user, "rosa"
set :domain, "195.19.76.12" # "abs.rosalab.ru"
set :port, 1822 # 222
set :use_sudo, false
set :deploy_to, "/srv/#{application}"
role :app, domain
role :web, domain
role :db, domain, :primary => true
set :keep_releases, 3
2011-10-25 23:30:39 +01:00
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-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"
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
namespace :deploy do
task :restart, :roles => :app, :except => { :no_release => true } do
2011-10-25 14:23:20 +01:00
## DISABLED: run "cd #{deploy_to}/current ; ([ -f tmp/pids/unicorn.pid ] && kill -USR2 `cat tmp/pids/unicorn.pid`); true"
run ["#{current_path}/script/unicorn reload"].join("; ")
2011-04-11 18:07:49 +01:00
restart_dj
end
%w(start).each { |name| task name, :roles => :app do deploy.restart end }
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-04-15 14:20:48 +01:00
# desc 'Bundle and minify the JS and CSS files'
# task :build_assets, :roles => :app do
# root_path = File.expand_path(File.dirname(__FILE__) + '/..')
# assets_path = "#{root_path}/public/assets"
# envs = "RAILS_ENV=production"
#
# # Precaching assets
# run_locally "bash -c '#{envs} jammit'"
#
# # Uploading prechached assets
# top.upload assets_path, "#{current_release}/public", :via => :scp, :recursive => true
# end
after "deploy:update_code", :roles => :web do
2011-04-15 14:20:48 +01:00
# build_assets
2011-03-29 18:06:21 +01:00
symlink_config_files
2011-10-29 22:21:49 +01:00
generate_roles
end
2011-10-29 22:21:49 +01:00
2011-03-29 18:06:21 +01:00
end