Skip to content

Commit

Permalink
udate README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
SunDi3yansyah committed Oct 2, 2016
1 parent 4ab5ad8 commit 79dea0b
Showing 1 changed file with 25 additions and 15 deletions.
40 changes: 25 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,22 @@

Add this line to your application's Gemfile:

gem 'capistrano', '~> 3.0'
gem 'capistrano-maintenance', '~> 1.0', require: false

``` ruby
gem 'capistrano', '~> 3.0'
gem 'capistrano-maintenance', '~> 1.0', require: false
```

And then execute:

$ bundle
``` bash
$ bundle
```

Or install it yourself:

$ gem install capistrano-maintenance
``` bash
$ gem install capistrano-maintenance
```

## Usage

Expand All @@ -24,7 +29,7 @@ Application servers such as [Passenger](https://www.phusionpassenger.com) and [u

Here is an example config for **nginx**. Note that this is just a part of the complete config, and will probably require modifications.

```
``` nginx
error_page 503 @503;
# Return a 503 error if the maintenance page exists.
Expand All @@ -46,7 +51,7 @@ location @503 {

And here is an example config for **Apache**. This will also need to be modified.

```
``` apache
# Create an alias to the maintenance page used as error document.
Alias "/error" "/var/www/domain.com/shared/public/system/"
ErrorDocument 503 /error/maintenance.html
Expand All @@ -64,20 +69,24 @@ RewriteRule ^/(.*)$ balancer://unicornserver%{REQUEST_URI} [P,QSA,L]

You can now require the gem in your `Capfile`:

require 'capistrano/maintenance'
```
require 'capistrano/maintenance'
```

### Enable task

Present a maintenance page to visitors. Disables your application's web
interface by writing a "#{maintenance_basename}.html" file to each web server. The
Present a maintenance page to visitors. Disables your application's web interface
by writing a `"#{maintenance_basename}.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 maintenance:enable REASON="hardware upgrade" UNTIL="12pm Central Time"
```
cap maintenance:enable REASON="hardware upgrade" UNTIL="12pm Central Time"
```

You can use a different template for the maintenance page by setting the
`:maintenance_template_path` variable in your deploy.rb file with an absolute path.
Expand All @@ -88,7 +97,7 @@ set :maintenance_template_path, File.expand_path("../../app/path/to/maintenance.

The template file should either be a plaintext or an erb file. For example:

```
``` html
<!DOCTYPE html>
<html>
<head>
Expand All @@ -114,17 +123,18 @@ The template file should either be a plaintext or an erb file. For example:
<p>It'll be back <%= deadline ? deadline : "shortly" %>.</p>
</body>
</html>
```

Further customization will require that you write your own task.

### Disable task

cap maintenance:disable
``` bash
cap maintenance:disable
```

Makes the application web-accessible again. Removes the
"#{maintenance_basename}.html" page generated by maintenance:disable, which (if your
`"#{maintenance_basename}.html"` page generated by maintenance:disable, which (if your
web servers are configured correctly) will make your application web-accessible again.

## Contributing
Expand Down

0 comments on commit 79dea0b

Please sign in to comment.