- Easy installation
- Rake commands to turn maintenance mode on and off
- Easily provide a reason for each downtime without editing the maintenance.html file
- Allow certain IPs or IP ranges to bypass the maintenance page
- Allow certain paths to be accessible during maintenance
- Easily override the default maintenance.html file with your own
- Simple YAML based config file for easy activation, deactivation and configuration without the rake commands
- Supports Rails 2.3 - 3.0 and Ruby 1.8.7 - 1.9.3
config/environment.rb file add:
then in your
rake maintenance:start reason="Somebody googled Google!"
rake maintenance:start allowed_paths="/login,^/faqs/[0-9]*"
rake maintenance:start allowed_ips="220.127.116.11"
rake maintenance:start reason="Someone told me I should type <code>sudo rm -rf /</code>" allowed_paths="^/help,^/contact_us" allowed_ips="127.0.0.1,192.168.0.0/24"
reasonparameter can contain HTML
allowed_ipscan be given. Just comma separate them.
allowed_pathsare treated as regular expressions.
- If you need to use a comma in an
allowed_pathsregular expression just escape it with a backslash:
- IP ranges can be given to
allowed_ipsusing CIDR notation.
A default maintenance page is provided, but you can create your own
public/maintenance.html instead. If you provide a
reason to the rake task, Turnout will use Nokogiri to parse the
maintenance.html file and attempt to find a tag with
id="reason". It will replace the
inner_html of the tag with the reason you provided. So be sure your
maintenance.html file can be parsed as HTML.
There is no
denied_paths feature because turnout denies everyhing by default.
However you can achieve the same sort of functionality by using
negative lookaheads with the
allowed_paths setting, like so:
rake maintenance:start allowed_paths="^(?!/your/under/maintenance/path)"
Behind the Scenes
On every request the Rack app will check to see if
tmp/maintenance.yml exists. If the file exists the maintenance page will be shown (unless allowed IPs are given and the requester is in the allowed range).
So if you want to get the maintenance page up or down in a hury
touch tmp/maintenance.yml and
rm tmp/maintenance.yml will work.
Turnout will attempt to parse the
maintenance.yml file looking for
allowed_ip settings. The file is not cached so you can change these values manually or just rerun the
rake maintenance:start command.
Example maintenance.yml File
--- reason: Someone told me I should type <code>sudo rm -rf /</code> allowed_paths: - ^/help - ^/contact_us allowed_ips: - 127.0.0.1 - 192.168.0.0/24