August 12th, 2007

Here is a version 2.0 amendment to Mike Clark’s great tutorial on creating custom maintenance pages with Capistrano. It’s required because, as Jamis explains here, render has been taken out of Capistrano 2.0.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

namespace :deploy do
  namespace :web do
    task :disable, :roles => :web do
      # invoke with  
      # UNTIL="16:00 MST" REASON="a database upgrade" cap deploy:web:disable

      on_rollback { rm "#{shared_path}/system/maintenance.html" }

      require 'erb'
      deadline, reason = ENV['UNTIL'], ENV['REASON']
      maintenance = ERB.new(File.read("./app/views/layouts/maintenance.erb")).result(binding)

      put maintenance, "#{shared_path}/system/maintenance.html", :mode => 0644
    end
  end
end
0 comments »