rosa-build/config/deploy.rb

77 lines
2.1 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'
2011-10-31 17:50:45 +00:00
set :whenever_command, "bundle exec whenever"
require "whenever/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"
2011-10-30 19:32:13 +00:00
set :domain, "195.19.76.12" # "npp-build.rosalab.ru"
set :port, 1822
2011-10-25 23:30:39 +01:00
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-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
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
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
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-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