capistrano-maintenance 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +19 -2
- data/Rakefile +10 -0
- data/lib/capistrano/maintenance.rb +30 -27
- data/lib/capistrano/maintenance/version.rb +1 -1
- metadata +3 -2
data/README.md
CHANGED
@@ -8,10 +8,27 @@ Usage
|
|
8
8
|
|
9
9
|
Install the gem via rubygems:
|
10
10
|
|
11
|
-
|
11
|
+
gem install capistrano-maintenance
|
12
12
|
|
13
13
|
And put this line into your deploy.rb file:
|
14
14
|
|
15
|
-
|
15
|
+
require 'capistrano/maintenance'
|
16
16
|
|
17
17
|
That's it. Everthing works like expected.
|
18
|
+
|
19
|
+
Configuration
|
20
|
+
-------------
|
21
|
+
|
22
|
+
Everything should work out of the box general, but there are some additional adjustments you can make in your deploy.rb.
|
23
|
+
|
24
|
+
# change the default filename from maintenance.html to disabled.html
|
25
|
+
set :maintenance_basename, 'disabled'
|
26
|
+
|
27
|
+
# change default directory from default of #{shared_path}/system
|
28
|
+
set :maintenance_dirname, "#{shared_path}/public/system"
|
29
|
+
|
30
|
+
# use local template instead of included one with capistrano-maintenance
|
31
|
+
set :maintenance_template_path, 'app/views/maintenance.html'
|
32
|
+
|
33
|
+
# disable the warning on how to configure your server
|
34
|
+
set :maintenance_config_warning, false
|
data/Rakefile
ADDED
@@ -5,6 +5,7 @@ module Capistrano::Maintenance
|
|
5
5
|
def self.load_into(configuration)
|
6
6
|
configuration.load do
|
7
7
|
|
8
|
+
_cset(:maintenance_dirname) { "#{shared_path}/system" }
|
8
9
|
_cset :maintenance_basename, "maintenance"
|
9
10
|
_cset(:maintenance_template_path) { File.join(File.dirname(__FILE__), "templates", "maintenance.html.erb") }
|
10
11
|
|
@@ -34,31 +35,33 @@ module Capistrano::Maintenance
|
|
34
35
|
DESC
|
35
36
|
task :disable, :roles => :web, :except => { :no_release => true } do
|
36
37
|
require 'erb'
|
37
|
-
on_rollback { run "rm -f #{
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
38
|
+
on_rollback { run "rm -f #{mainteannce_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
|
62
65
|
|
63
66
|
reason = ENV['REASON']
|
64
67
|
deadline = ENV['UNTIL']
|
@@ -66,7 +69,7 @@ module Capistrano::Maintenance
|
|
66
69
|
template = File.read(maintenance_template_path)
|
67
70
|
result = ERB.new(template).result(binding)
|
68
71
|
|
69
|
-
put result, "#{
|
72
|
+
put result, "#{maintenance_dirname}/#{maintenance_basename}.html", :mode => 0644
|
70
73
|
end
|
71
74
|
|
72
75
|
desc <<-DESC
|
@@ -76,7 +79,7 @@ module Capistrano::Maintenance
|
|
76
79
|
web-accessible again.
|
77
80
|
DESC
|
78
81
|
task :enable, :roles => :web, :except => { :no_release => true } do
|
79
|
-
run "rm -f #{
|
82
|
+
run "rm -f #{maintenance_dirname}/#{maintenance_basename}.html"
|
80
83
|
end
|
81
84
|
|
82
85
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-03-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: capistrano
|
@@ -36,6 +36,7 @@ extra_rdoc_files: []
|
|
36
36
|
files:
|
37
37
|
- .gitignore
|
38
38
|
- README.md
|
39
|
+
- Rakefile
|
39
40
|
- capistrano-maintenance.gemspec
|
40
41
|
- lib/capistrano/maintenance.rb
|
41
42
|
- lib/capistrano/maintenance/version.rb
|