Sha256: db077690d2b9f1e64545074b4d5d8ad2d0d30283c82ec9db55f4f43aef3ab6be

Contents?: true

Size: 1.53 KB

Versions: 3

Compression:

Stored size: 1.53 KB

Contents

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

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
capistrano-2.5.6 lib/capistrano/recipes/ext/web-disable-enable.rb
capistrano-2.5.7 lib/capistrano/recipes/ext/web-disable-enable.rb
capistrano-edge-2.5.6 lib/capistrano/recipes/ext/web-disable-enable.rb