Skip to content

Instantly share code, notes, and snippets.

@orlin
Created February 17, 2010 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save orlin/306630 to your computer and use it in GitHub Desktop.
Save orlin/306630 to your computer and use it in GitHub Desktop.
Heroku Maintenance Mode
# $ heroku maintenance:on
# $ heroku maintenance:off
# side-effect for any GETs during and then after Maintenance Mode ...
# the maintenance page stays cached (in place of the real ones) - until: Cmd + Shift + R
require 'rubygems'
if ENV['MAINTENANCE_MODE']
require 'rack'
require 'rack/maintenance'
require 'rack-rewrite'
html = "index.html"
path = File.join('public', 'maintenance')
file = File.join(path, html)
use Rack::Static,
:urls => ["/#{html}",
"/images",
"/stylesheets"],
:root => path
use Rack::Maintenance,
:file => file
use Rack::Rewrite do
send_file /.*/, file, :if => Proc.new { |rack_env|
File.exists?(file) && rack_env['REQUEST_URI'] !~ /\.(css|jpg|png)/
}
end
else
# run App
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment