Skip to content

Commit

Permalink
add missing deployment tasks (create db and load reference data); rem…
Browse files Browse the repository at this point in the history
…ove extra namespace in logrotate tasks; add hooks to niet tasks
  • Loading branch information
Shevaun Coker committed May 29, 2012
1 parent 29f17af commit 2c6068e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 10 deletions.
31 changes: 27 additions & 4 deletions lib/easy/deployment/capistrano.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 4 additions & 6 deletions lib/easy/deployment/logrotate.rb
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions lib/easy/deployment/niet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,8 @@
run "ps -fu deploy"
end
end

# niet hooks
after 'deploy:start', 'niet:start'
after 'deploy:restart', 'niet:restart'
end

0 comments on commit 2c6068e

Please sign in to comment.