From 2c6068eadd83de6c9f03c67eea7962dcbd7823b4 Mon Sep 17 00:00:00 2001 From: Shevaun Coker Date: Tue, 29 May 2012 14:58:33 +1200 Subject: [PATCH] add missing deployment tasks (create db and load reference data); remove extra namespace in logrotate tasks; add hooks to niet tasks --- lib/easy/deployment/capistrano.rb | 31 +++++++++++++++++++++++++++---- lib/easy/deployment/logrotate.rb | 10 ++++------ lib/easy/deployment/niet.rb | 4 ++++ 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/lib/easy/deployment/capistrano.rb b/lib/easy/deployment/capistrano.rb index 013985f..00261ec 100644 --- a/lib/easy/deployment/capistrano.rb +++ b/lib/easy/deployment/capistrano.rb @@ -15,13 +15,36 @@ update # updates_code and creates symlink create_db migrate - top.namespace :easy do - namespace(:logrotate){setup} - namespace(:apache) {configure} - end + top.namespace(:logrotate) {setup} + top.namespace(:apache) {configure} restart end + desc "Create the database" + task :create_db, :roles => :db, :only => {:primary => true} do + migrate_target = fetch(:migrate_target, :latest) + + directory = case migrate_target.to_sym + when :current then current_path + when :latest then latest_release + else raise ArgumentError, "unknown migration target #{migrate_target.inspect}" + end + run "cd #{directory}; RAILS_ENV=#{stage} bundle exec rake db:create" + end + + desc "Load reference data" + task :reference_data, :roles => :db, :only => { :primary => true } do + migrate_target = fetch(:migrate_target, :latest) + + directory = case migrate_target.to_sym + when :current then current_path + when :latest then latest_release + else raise ArgumentError, "unknown migration target #{migrate_target.inspect}" + end + + run "cd #{directory} && RAILS_ENV=#{stage} bundle exec rake reference:load" + end + # By default, we deploy using passenger as an app server task :start do ; end task :stop do ; end diff --git a/lib/easy/deployment/logrotate.rb b/lib/easy/deployment/logrotate.rb index c36ead0..c1b8b2e 100644 --- a/lib/easy/deployment/logrotate.rb +++ b/lib/easy/deployment/logrotate.rb @@ -1,11 +1,9 @@ # To load this capistrano configuration, require 'easy/deployment/logrotate' from deploy.rb Capistrano::Configuration.instance(:must_exist).load do - namespace :easy do - namespace :logrotate do - desc "Copies the application logrotate file into /etc/logrotate.d" - task :setup, :except => { :no_release => true } do - run "cp #{current_path}/config/deploy/#{stage}/logrotate.conf /etc/logrotate.d/#{application}.conf" - end + namespace :logrotate do + desc "Copies the application logrotate file into /etc/logrotate.d" + task :setup, :except => { :no_release => true } do + run "cp #{current_path}/config/deploy/#{stage}/logrotate.conf /etc/logrotate.d/#{application}.conf" end end end diff --git a/lib/easy/deployment/niet.rb b/lib/easy/deployment/niet.rb index 233bd06..8213886 100644 --- a/lib/easy/deployment/niet.rb +++ b/lib/easy/deployment/niet.rb @@ -25,4 +25,8 @@ run "ps -fu deploy" end end + + # niet hooks + after 'deploy:start', 'niet:start' + after 'deploy:restart', 'niet:restart' end