# Standard tasks that are useful for most recipes. It makes a few assumptions: # # * The :app role has been defined as the set of machines consisting of the # application servers. # * The :web role has been defined as the set of machines consisting of the # web servers. # * The Rails spinner and reaper scripts are being used to manage the FCGI # processes. # * There is a script in script/ called "reap" that restarts the FCGI processes desc "Enumerate and describe every available task." task :show_tasks do keys = tasks.keys.sort_by { |a| a.to_s } longest = keys.inject(0) { |len,key| key.to_s.length > len ? key.to_s.length : len } + 2 puts "Available tasks" puts "---------------" tasks.keys.sort_by { |a| a.to_s }.each do |key| desc = (tasks[key].options[:desc] || "").strip.split(/\r?\n/) puts "%-#{longest}s %s" % [key, desc.shift] puts "%#{longest}s %s" % ["", desc.shift] until desc.empty? puts end end desc "Set up the expected application directory structure on all boxes" task :setup do run <<-CMD mkdir -p -m 775 #{releases_path} #{shared_path}/system && mkdir -p -m 777 #{shared_path}/log CMD end desc < :web do on_rollback { delete "#{shared_path}/system/maintenance.html" } maintenance = render("maintenance", :deadline => ENV['UNTIL'], :reason => ENV['REASON']) put maintenance, "#{shared_path}/system/maintenance.html", :mode => 0644 end desc %(Re-enable the web server by deleting any "maintenance.html" file.) task :enable_web, :roles => :web do delete "#{shared_path}/system/maintenance.html" end desc < true } source.checkout(self) run <<-CMD rm -rf #{release_path}/log #{release_path}/public/system && ln -nfs #{shared_path}/log #{release_path}/log && ln -nfs #{shared_path}/system #{release_path}/public/system CMD end desc < :app do sudo "#{current_path}/script/reap" end desc < :db, :only => { :primary => true } do run "cd #{current_path} && rake RAILS_ENV=production migrate" end desc <