beast rev 2066
[beast-modified.git] / lib / tasks / capistrano.rake
blob08642ac7e35f7dba75a4f715fc421860e3b1f439
1 # =============================================================================
2 # A set of rake tasks for invoking the Capistrano automation utility.
3 # =============================================================================
5 # Invoke the given actions via Capistrano
6 def cap(*parameters)
7   begin
8     require 'rubygems'
9   rescue LoadError
10     # no rubygems to load, so we fail silently
11   end
13   require 'capistrano/cli'
15   Capistrano::CLI.new(parameters.map { |param| param.to_s }).execute!
16 end
18 namespace :remote do
19   desc "Removes unused releases from the releases directory."
20   task(:cleanup) { cap :cleanup }
22   desc "Used only for deploying when the spinner isn't running."
23   task(:cold_deploy) { cap :cold_deploy }
25   desc "A macro-task that updates the code, fixes the symlink, and restarts the application servers."
26   task(:deploy) { cap :deploy }
28   desc "Similar to deploy, but it runs the migrate task on the new release before updating the symlink."
29   task(:deploy_with_migrations) { cap :deploy_with_migrations }
31   desc "Displays the diff between HEAD and what was last deployed."
32   task(:diff_from_last_deploy) { cap :diff_from_last_deploy }
34   desc "Disable the web server by writing a \"maintenance.html\" file to the web servers."
35   task(:disable_web) { cap :disable_web }
37   desc "Re-enable the web server by deleting any \"maintenance.html\" file."
38   task(:enable_web) { cap :enable_web }
40   desc "A simple task for performing one-off commands that may not require a full task to be written for them."
41   task(:invoke) { cap :invoke }
43   desc "Run the migrate rake task."
44   task(:migrate) { cap :migrate }
46   desc "Restart the FCGI processes on the app server."
47   task(:restart) { cap :restart }
49   desc "A macro-task that rolls back the code and restarts the application servers."
50   task(:rollback) { cap :rollback }
52   desc "Rollback the latest checked-out version to the previous one by fixing the symlinks and deleting the current release from all servers."
53   task(:rollback_code) { cap :rollback_code }
55   desc "Set up the expected application directory structure on all boxes"
56   task(:setup) { cap :setup }
58   desc "Enumerate and describe every available task."
59   task(:show_tasks) { cap :show_tasks, '-q' }
61   desc "Start the spinner daemon for the application (requires script/spin)."
62   task(:spinner) { cap :spinner }
64   desc "Update the 'current' symlink to point to the latest version of the application's code."
65   task(:symlink) { cap :symlink }
67   desc "Update all servers with the latest release of the source code."
68   task(:update_code) { cap :update_code }
70   desc "Update the currently released version of the software directly via an SCM update operation"
71   task(:update_current) { cap :update_current }
73   desc "Execute a specific action using capistrano"
74   task :exec do
75     unless ENV['ACTION']
76       raise "Please specify an action (or comma separated list of actions) via the ACTION environment variable"
77     end
79     actions = ENV['ACTION'].split(",")
80     actions.concat(ENV['PARAMS'].split(" ")) if ENV['PARAMS']
82     cap(*actions)
83   end
84 end
86 desc "Push the latest revision into production (delegates to remote:deploy)"
87 task :deploy => "remote:deploy"
89 desc "Rollback to the release before the current release in production (delegates to remote:rollback)"
90 task :rollback => "remote:rollback"