Add Capistrano task to automate maintenance mode

This commit is contained in:
Angel Perez
2017-09-27 18:39:09 -04:00
committed by Angel Perez
parent bb1e5e4608
commit c643656067
4 changed files with 29 additions and 1 deletions

1
.gitignore vendored
View File

@@ -20,6 +20,7 @@
/config/database.yml
/config/secrets.yml
/config/deploy-secrets.yml
/config/maintenance.yml
/coverage

View File

@@ -1,5 +1,5 @@
# config valid only for current version of Capistrano
lock '3.8.1'
lock '3.8.2'
def deploysecret(key)
@deploy_secrets_yml ||= YAML.load_file('config/deploy-secrets.yml')[fetch(:stage).to_s]

View File

@@ -0,0 +1,12 @@
---
app_root: '.'
allowed_ips:
- 127.0.0.1
- x.x.x.x
allowed_paths:
- your/custom/route
reason: 'Website down for maintenance'
response_code: 503
retry_after: 3600

View File

@@ -0,0 +1,15 @@
namespace :maintenance do
desc "Start maintenance mode (edit config/maintenance.yml to provide parameters)"
task :start do
on roles(:app) do
upload! "config/maintenance.yml", "#{current_path}/tmp/maintenance.yml"
end
end
desc "Stop maintenance mode"
task :stop do
on roles(:app) do
execute "rm #{current_path}/tmp/maintenance.yml"
end
end
end