capistrano-maintenance 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +45 -19
- data/capistrano-maintenance.gemspec +1 -2
- data/lib/capistrano/maintenance/version.rb +4 -2
- data/lib/capistrano/maintenance.rb +78 -81
- metadata +10 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bfa25fd8964b5920d1f82d422f2671eeb7dadd36
|
4
|
+
data.tar.gz: 569d7a6c4610b3f245701ebefce92837b5e2ad8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0579666e4ec68db548a31483c4f23e66e7ae42a1c650eb4c73b20e5bd00c6a885682e339fd997c1f4abd8511dd0c2bba5d5ec0d15fd9e58b775d1e4ebf7bcf43
|
7
|
+
data.tar.gz: d57033fe692fb3e19b2e224ab053a4d10de5aac12af5cb4748d86aaef2d5d6440c0725e837de713bf4fd1af944bcc211e3ddabc97ff869a409c11faa0ad6ee6e
|
data/README.md
CHANGED
@@ -1,53 +1,79 @@
|
|
1
|
-
Capistrano Maintenance Extension
|
2
|
-
|
1
|
+
Capistrano 2 Maintenance Extension
|
2
|
+
==================================
|
3
3
|
|
4
|
-
This gem simply offers the recently removed `deploy:web:disable` and `deploy:web:enable` tasks to your Capistrano deployment.
|
4
|
+
This gem simply offers the recently removed `deploy:web:disable` and `deploy:web:enable` tasks to your Capistrano 2 deployment.
|
5
|
+
|
6
|
+
**NOTE** This version only works with Capistrano 2.x. For a Capistrano 3 compatible version please use [the official extension](https://github.com/capistrano/maintenance).
|
5
7
|
|
6
8
|
Usage
|
7
9
|
-----
|
8
10
|
|
9
11
|
Install the gem via rubygems:
|
10
12
|
|
11
|
-
|
13
|
+
```sh
|
14
|
+
gem install capistrano-maintenance --version=0.0.5
|
15
|
+
```
|
16
|
+
|
17
|
+
or use bundler:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
# Gemfile
|
21
|
+
gem 'capistrano-maintenance', '0.0.5', group: 'development'
|
22
|
+
```
|
23
|
+
|
24
|
+
```sh
|
25
|
+
bundle install
|
26
|
+
```
|
12
27
|
|
13
28
|
And put this line into your deploy.rb file:
|
14
29
|
|
15
|
-
|
30
|
+
```ruby
|
31
|
+
require 'capistrano/maintenance'
|
32
|
+
```
|
16
33
|
|
17
34
|
Now, you can disable the web:
|
18
35
|
|
19
|
-
|
36
|
+
```sh
|
37
|
+
cap deploy:web:disable
|
38
|
+
```
|
20
39
|
|
21
40
|
You can also specify a string to specify reason and how long it is until:
|
22
41
|
|
23
|
-
|
24
|
-
|
42
|
+
```sh
|
43
|
+
cap deploy:web:disable REASON="For server upgrades" UNTIL="3AM EST"
|
44
|
+
```
|
25
45
|
|
26
46
|
When maintenance is done, you can enable the web:
|
27
47
|
|
28
|
-
|
48
|
+
```sh
|
49
|
+
cap deploy:web:enable
|
50
|
+
```
|
29
51
|
|
30
52
|
If you are using [multistage capistrano](https://github.com/capistrano/capistrano/wiki/2.x-Multistage-Extension), you'll also need to include the stage before `deploy:web:disable` and `deploy:web:enable`:
|
31
53
|
|
32
|
-
|
33
|
-
|
54
|
+
```sh
|
55
|
+
cap production deploy:web:disable
|
56
|
+
cap production deploy:web:enable
|
57
|
+
```
|
34
58
|
|
35
59
|
Configuration
|
36
60
|
-------------
|
37
61
|
|
38
62
|
Everything should work out of the box general, but there are some additional adjustments you can make in your deploy.rb.
|
39
63
|
|
40
|
-
|
41
|
-
|
64
|
+
```ruby
|
65
|
+
# change the default filename from maintenance.html to disabled.html
|
66
|
+
set :maintenance_basename, 'disabled'
|
42
67
|
|
43
|
-
|
44
|
-
|
68
|
+
# change default directory from default of #{shared_path}/system
|
69
|
+
set :maintenance_dirname, "#{shared_path}/public/system"
|
45
70
|
|
46
|
-
|
47
|
-
|
71
|
+
# use local template instead of included one with capistrano-maintenance
|
72
|
+
set :maintenance_template_path, 'app/views/maintenance.html.erb'
|
48
73
|
|
49
|
-
|
50
|
-
|
74
|
+
# disable the warning on how to configure your server
|
75
|
+
set :maintenance_config_warning, false
|
76
|
+
```
|
51
77
|
|
52
78
|
For your custom maintenance template, you have access to the following variables, if they're defined:
|
53
79
|
|
@@ -1,6 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
require "capistrano"
|
4
3
|
require "capistrano/maintenance/version"
|
5
4
|
|
6
5
|
Gem::Specification.new do |s|
|
@@ -17,5 +16,5 @@ Gem::Specification.new do |s|
|
|
17
16
|
s.files = `git ls-files`.split("\n")
|
18
17
|
s.require_paths = ["lib"]
|
19
18
|
|
20
|
-
s.add_dependency 'capistrano', ['
|
19
|
+
s.add_dependency 'capistrano', ['~> 2.0']
|
21
20
|
end
|
@@ -1,95 +1,92 @@
|
|
1
1
|
require 'capistrano'
|
2
2
|
|
3
|
-
module Capistrano
|
4
|
-
|
5
|
-
def self.load_into(configuration)
|
6
|
-
configuration.load do
|
7
|
-
|
8
|
-
_cset(:maintenance_dirname) { "#{shared_path}/system" }
|
9
|
-
_cset :maintenance_basename, "maintenance"
|
10
|
-
_cset(:maintenance_template_path) { File.join(File.dirname(__FILE__), "templates", "maintenance.html.erb") }
|
11
|
-
|
12
|
-
namespace :deploy do
|
13
|
-
|
14
|
-
namespace :web do
|
15
|
-
|
16
|
-
desc <<-DESC
|
17
|
-
Present a maintenance page to visitors. Disables your application's web \
|
18
|
-
interface by writing a "#{maintenance_basename}.html" file to each web server. The \
|
19
|
-
servers must be configured to detect the presence of this file, and if \
|
20
|
-
it is present, always display it instead of performing the request.
|
21
|
-
|
22
|
-
By default, the maintenance page will just say the site is down for \
|
23
|
-
"maintenance", and will be back "shortly", but you can customize the \
|
24
|
-
page by specifying the REASON and UNTIL environment variables:
|
25
|
-
|
26
|
-
$ cap deploy:web:disable \\
|
27
|
-
REASON="hardware upgrade" \\
|
28
|
-
UNTIL="12pm Central Time"
|
29
|
-
|
30
|
-
You can use a different template for the maintenance page by setting the \
|
31
|
-
:maintenance_template_path variable in your deploy.rb file. The template file \
|
32
|
-
should either be a plaintext or an erb file.
|
33
|
-
|
34
|
-
Further customization will require that you write your own task.
|
35
|
-
DESC
|
36
|
-
task :disable, :roles => :web, :except => { :no_release => true } do
|
37
|
-
require 'erb'
|
38
|
-
on_rollback { run "rm -f #{maintenance_dirname}/#{maintenance_basename}.html" }
|
39
|
-
|
40
|
-
if fetch(:maintenance_config_warning, true)
|
41
|
-
warn <<-EOHTACCESS
|
42
|
-
|
43
|
-
# Please add something like this to your site's Apache htaccess to redirect users to the maintenance page.
|
44
|
-
# More Info: http://www.shiftcommathree.com/articles/make-your-rails-maintenance-page-respond-with-a-503
|
45
|
-
|
46
|
-
ErrorDocument 503 /system/#{maintenance_basename}.html
|
47
|
-
RewriteEngine On
|
48
|
-
RewriteCond %{REQUEST_URI} !\.(css|gif|jpg|png)$
|
49
|
-
RewriteCond %{DOCUMENT_ROOT}/system/#{maintenance_basename}.html -f
|
50
|
-
RewriteCond %{SCRIPT_FILENAME} !#{maintenance_basename}.html
|
51
|
-
RewriteRule ^.*$ - [redirect=503,last]
|
52
|
-
|
53
|
-
# Or if you are using Nginx add this to your server config:
|
54
|
-
|
55
|
-
if (-f $document_root/system/maintenance.html) {
|
56
|
-
return 503;
|
57
|
-
}
|
58
|
-
error_page 503 @maintenance;
|
59
|
-
location @maintenance {
|
60
|
-
rewrite ^(.*)$ /system/maintenance.html last;
|
61
|
-
break;
|
62
|
-
}
|
63
|
-
EOHTACCESS
|
64
|
-
end
|
3
|
+
module Capistrano
|
4
|
+
module Maintenance
|
65
5
|
|
66
|
-
|
67
|
-
|
6
|
+
def self.load_into(configuration)
|
7
|
+
configuration.load do
|
68
8
|
|
69
|
-
|
70
|
-
|
9
|
+
_cset(:maintenance_dirname) { "#{shared_path}/system" }
|
10
|
+
_cset :maintenance_basename, "maintenance"
|
11
|
+
_cset(:maintenance_template_path) { File.join(File.dirname(__FILE__), "templates", "maintenance.html.erb") }
|
71
12
|
|
72
|
-
|
73
|
-
end
|
13
|
+
namespace :deploy do
|
74
14
|
|
75
|
-
|
76
|
-
Makes the application web-accessible again. Removes the \
|
77
|
-
"#{maintenance_basename}.html" page generated by deploy:web:disable, which (if your \
|
78
|
-
web servers are configured correctly) will make your application \
|
79
|
-
web-accessible again.
|
80
|
-
DESC
|
81
|
-
task :enable, :roles => :web, :except => { :no_release => true } do
|
82
|
-
run "rm -f #{maintenance_dirname}/#{maintenance_basename}.html"
|
83
|
-
end
|
15
|
+
namespace :web do
|
84
16
|
|
85
|
-
|
17
|
+
desc <<-DESC
|
18
|
+
Present a maintenance page to visitors. Disables your application's web \
|
19
|
+
interface by writing a "#{maintenance_basename}.html" file to each web server. The \
|
20
|
+
servers must be configured to detect the presence of this file, and if \
|
21
|
+
it is present, always display it instead of performing the request.
|
86
22
|
|
87
|
-
|
23
|
+
By default, the maintenance page will just say the site is down for \
|
24
|
+
"maintenance", and will be back "shortly", but you can customize the \
|
25
|
+
page by specifying the REASON and UNTIL environment variables:
|
88
26
|
|
89
|
-
|
27
|
+
$ cap deploy:web:disable \\
|
28
|
+
REASON="hardware upgrade" \\
|
29
|
+
UNTIL="12pm Central Time"
|
90
30
|
|
91
|
-
|
31
|
+
You can use a different template for the maintenance page by setting the \
|
32
|
+
:maintenance_template_path variable in your deploy.rb file. The template file \
|
33
|
+
should either be a plaintext or an erb file.
|
34
|
+
|
35
|
+
Further customization will require that you write your own task.
|
36
|
+
DESC
|
37
|
+
task :disable, :roles => :web, :except => { :no_release => true } do
|
38
|
+
require 'erb'
|
39
|
+
on_rollback { run "rm -f #{maintenance_dirname}/#{maintenance_basename}.html" }
|
40
|
+
|
41
|
+
if fetch(:maintenance_config_warning, true)
|
42
|
+
warn <<-EOHTACCESS
|
43
|
+
|
44
|
+
# Please add something like this to your site's Apache htaccess to redirect users to the maintenance page.
|
45
|
+
# More Info: http://www.shiftcommathree.com/articles/make-your-rails-maintenance-page-respond-with-a-503
|
46
|
+
|
47
|
+
ErrorDocument 503 /system/#{maintenance_basename}.html
|
48
|
+
RewriteEngine On
|
49
|
+
RewriteCond %{REQUEST_URI} !\.(css|gif|jpg|png)$
|
50
|
+
RewriteCond %{DOCUMENT_ROOT}/system/#{maintenance_basename}.html -f
|
51
|
+
RewriteCond %{SCRIPT_FILENAME} !#{maintenance_basename}.html
|
52
|
+
RewriteRule ^.*$ - [redirect=503,last]
|
53
|
+
|
54
|
+
# Or if you are using Nginx add this to your server config:
|
92
55
|
|
56
|
+
if (-f $document_root/system/maintenance.html) {
|
57
|
+
return 503;
|
58
|
+
}
|
59
|
+
error_page 503 @maintenance;
|
60
|
+
location @maintenance {
|
61
|
+
rewrite ^(.*)$ /system/maintenance.html last;
|
62
|
+
break;
|
63
|
+
}
|
64
|
+
EOHTACCESS
|
65
|
+
end
|
66
|
+
|
67
|
+
reason = ENV['REASON']
|
68
|
+
deadline = ENV['UNTIL']
|
69
|
+
|
70
|
+
template = File.read(maintenance_template_path)
|
71
|
+
result = ERB.new(template).result(binding)
|
72
|
+
|
73
|
+
put result, "#{maintenance_dirname}/#{maintenance_basename}.html", :mode => 0644
|
74
|
+
end
|
75
|
+
|
76
|
+
desc <<-DESC
|
77
|
+
Makes the application web-accessible again. Removes the \
|
78
|
+
"#{maintenance_basename}.html" page generated by deploy:web:disable, which (if your \
|
79
|
+
web servers are configured correctly) will make your application \
|
80
|
+
web-accessible again.
|
81
|
+
DESC
|
82
|
+
task :enable, :roles => :web, :except => { :no_release => true } do
|
83
|
+
run "rm -f #{maintenance_dirname}/#{maintenance_basename}.html"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
93
90
|
end
|
94
91
|
|
95
92
|
if Capistrano::Configuration.instance
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-maintenance
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas von Deyen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.0
|
19
|
+
version: '2.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.0
|
26
|
+
version: '2.0'
|
27
27
|
description: The deploy:web tasks where removed from Capistrano core. This extension
|
28
28
|
brings them back.
|
29
29
|
email: tvd@magiclabs.de
|
@@ -31,7 +31,7 @@ executables: []
|
|
31
31
|
extensions: []
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
34
|
-
- .gitignore
|
34
|
+
- ".gitignore"
|
35
35
|
- Gemfile
|
36
36
|
- README.md
|
37
37
|
- Rakefile
|
@@ -49,19 +49,18 @@ require_paths:
|
|
49
49
|
- lib
|
50
50
|
required_ruby_version: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
56
|
requirements:
|
57
|
-
- -
|
57
|
+
- - ">="
|
58
58
|
- !ruby/object:Gem::Version
|
59
59
|
version: '0'
|
60
60
|
requirements: []
|
61
61
|
rubyforge_project:
|
62
|
-
rubygems_version: 2.
|
62
|
+
rubygems_version: 2.4.6
|
63
63
|
signing_key:
|
64
64
|
specification_version: 4
|
65
65
|
summary: Offers deploy:web:disable and deploy:web:enable tasks for Capistrano.
|
66
66
|
test_files: []
|
67
|
-
has_rdoc:
|