capistrano-maintenance 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -8,10 +8,27 @@ Usage
8
8
 
9
9
  Install the gem via rubygems:
10
10
 
11
- `gem install capistrano-maintenance`
11
+ gem install capistrano-maintenance
12
12
 
13
13
  And put this line into your deploy.rb file:
14
14
 
15
- `require 'capistrano/maintenance'`
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
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/gem_helper'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+
8
+ Bundler::GemHelper.install_tasks
9
+
10
+ task :default => :build
@@ -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 #{shared_path}/system/#{maintenance_basename}.html" }
38
-
39
- warn <<-EOHTACCESS
40
-
41
- # Please add something like this to your site's Apache htaccess to redirect users to the maintenance page.
42
- # More Info: http://www.shiftcommathree.com/articles/make-your-rails-maintenance-page-respond-with-a-503
43
-
44
- ErrorDocument 503 /system/#{maintenance_basename}.html
45
- RewriteEngine On
46
- RewriteCond %{REQUEST_URI} !\.(css|gif|jpg|png)$
47
- RewriteCond %{DOCUMENT_ROOT}/system/#{maintenance_basename}.html -f
48
- RewriteCond %{SCRIPT_FILENAME} !#{maintenance_basename}.html
49
- RewriteRule ^.*$ - [redirect=503,last]
50
-
51
- # Or if you are using Nginx add this to your server config:
52
-
53
- if (-f $document_root/system/maintenance.html) {
54
- return 503;
55
- }
56
- error_page 503 @maintenance;
57
- location @maintenance {
58
- rewrite ^(.*)$ /system/maintenance.html last;
59
- break;
60
- }
61
- EOHTACCESS
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, "#{shared_path}/system/#{maintenance_basename}.html", :mode => 0644
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 #{shared_path}/system/#{maintenance_basename}.html"
82
+ run "rm -f #{maintenance_dirname}/#{maintenance_basename}.html"
80
83
  end
81
84
 
82
85
  end
@@ -1,3 +1,3 @@
1
1
  module Capistrano::Maintenance
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  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.2
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: 2012-11-02 00:00:00.000000000 Z
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