Rack::Maintenance is a simple Rack middleware to detect the existence of a maintenance page and display that instead of incoming requests.


sudo gem install rack-maintenance

Installation with Bundler

In Gemfile:

gem 'rack-maintenance'

and then run `bundle`.


# html maintenance response
config.middleware.use 'Rack::Maintenance',
  :file => Rails.root.join('public', 'maintenance.html'),
  :env  => 'MAINTENANCE'

# json maintenance response
# it's up to you to provide a valid JSON file!
config.middleware.use 'Rack::Maintenance',
  :file => Rails.root.join('public', 'maintenance.json'),
  :env  => 'MAINTENANCE'

If :env is specified, all requests will be shown the maintenance page if the environment variable is set.

If :env is not specified, the maintenance page will be shown if it exists.

# Leave some paths enabled while site is down
# You'll usually want to exclude /assets if you'd like to retain CSS.
# It also works for allowing access to admin while the rest is in maintenance mode.
config.middleware.use 'Rack::Maintenance',
  :file => Rails.root.join('public', 'maintenance.html'),
  :without => /\A\/assets/

If :paths is specified, only the paths specified in the given regular expression will be put on maintenance mode. This is useful if you still want access to an admin interface, as shown on the example.

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix in a branch.

  • Add tests for it.

  • Commit, do not mess with Rakefile or VERSION (do that in a separate commit if you want a local version)

  • Push your branch.

  • Send me a pull request.


BSD. See LICENSE for details.