1
0
Fork 0
mirror of https://github.com/capistrano/capistrano synced 2023-03-27 23:21:18 -04:00

Starting to add the actual extra recipes against my better judgement

This commit is contained in:
Lee Hambley 2009-05-20 21:09:11 +01:00
parent 4b5999f5f2
commit be7eeba064
2 changed files with 45 additions and 4 deletions

View file

@ -50,16 +50,17 @@ files = {
# and restart your mongrel application, or if you rely on the database
# migration code, please uncomment the lines you require below
# require 'recipes/rails/mongrel'
# require 'recipes/rails/migrations'
# require 'recipes/rails/passenger_mod_rails'
# require 'ext/recipes/rails/mongrel'
# require 'ext/recipes/rails/migrations'
# require 'ext/recipes/rails/passenger_mod_rails'
# There are also new utility libaries shipped with the core these
# include the following, please see individual files for more
# documentation, or run `cap -T` with the following lines commented out
# to see what they make available.
# require 'recipes/apache'
# require 'ext/recipes/apache'
# require 'ext/recipes/web-disable-enable'
# If you aren't deploying to /u/apps/\#{application} on the target
# servers (which is the default), you can specify the actual location

View file

@ -0,0 +1,40 @@
namespace :web do
desc <<-DESC
Present a maintenance page to visitors. Disables your application's web \
interface by writing a "maintenance.html" file to each web server. The \
servers must be configured to detect the presence of this file, and if \
it is present, always display it instead of performing the request.
By default, the maintenance page will just say the site is down for \
"maintenance", and will be back "shortly", but you can customize the \
page by specifying the REASON and UNTIL environment variables:
$ cap deploy:web:disable \\
REASON="hardware upgrade" \\
UNTIL="12pm Central Time"
Further customization will require that you write your own task.
DESC
task :disable, :roles => :web, :except => { :no_release => true } do
require 'erb'
on_rollback { run "rm #{shared_path}/system/maintenance.html" }
reason = ENV['REASON']
deadline = ENV['UNTIL']
template = File.read(File.join(File.dirname(__FILE__), "templates", "maintenance.rhtml"))
result = ERB.new(template).result(binding)
put result, "#{shared_path}/system/maintenance.html", :mode => 0644
end
desc <<-DESC
Makes the application web-accessible again. Removes the \
"maintenance.html" page generated by deploy:web:disable, which (if your \
web servers are configured correctly) will make your application \
web-accessible again.
DESC
task :enable, :roles => :web, :except => { :no_release => true } do
run "rm #{shared_path}/system/maintenance.html"
end
end