capistrano-maintenance 0.0.1

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/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
data/README.md ADDED
@@ -0,0 +1,13 @@
1
+ Capistrano Maintenenace Extension
2
+ =================================
3
+
4
+ This gem simply offers the recently removed `deploy:web:disable` and `deploy:web:enable` tasks to your Capistrano deployment.
5
+
6
+ Usage
7
+ -----
8
+
9
+ Put this line into your deploy.rb file:
10
+
11
+ `require 'capistrano/maintenance'`
12
+
13
+ That's it. Everthing works like expected.
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "capistrano"
4
+ require "capistrano/maintenance/version"
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = 'capistrano-maintenance'
8
+ s.version = Capistrano::Maintenance::VERSION
9
+ s.platform = Gem::Platform::RUBY
10
+ s.license = 'MIT'
11
+ s.author = 'Thomas von Deyen'
12
+ s.email = 'tvd@magiclabs.de'
13
+ s.homepage = 'https://github.com/tvdeyen/capistrano-maintenance'
14
+ s.summary = %q{Offers deploy:web:disable and deploy:web:enable tasks for Capistrano.}
15
+ s.description = %q{The deploy:web tasks where removed from Capistrano core. This extension brings them back.}
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.require_paths = ["lib"]
19
+
20
+ s.add_dependency 'capistrano', ['>= 2.0.0']
21
+ end
@@ -0,0 +1,94 @@
1
+ require 'capistrano'
2
+
3
+ module Capistrano::Maintenance
4
+
5
+ def self.load_into(configuration)
6
+ configuration.load do
7
+
8
+ _cset :maintenance_basename, "maintenance"
9
+ _cset(:maintenance_template_path) { File.join(File.dirname(__FILE__), "templates", "maintenance.html.erb") }
10
+
11
+ namespace :deploy do
12
+
13
+ namespace :web do
14
+
15
+ desc <<-DESC
16
+ Present a maintenance page to visitors. Disables your application's web \
17
+ interface by writing a "#{maintenance_basename}.html" file to each web server. The \
18
+ servers must be configured to detect the presence of this file, and if \
19
+ it is present, always display it instead of performing the request.
20
+
21
+ By default, the maintenance page will just say the site is down for \
22
+ "maintenance", and will be back "shortly", but you can customize the \
23
+ page by specifying the REASON and UNTIL environment variables:
24
+
25
+ $ cap deploy:web:disable \\
26
+ REASON="hardware upgrade" \\
27
+ UNTIL="12pm Central Time"
28
+
29
+ You can use a different template for the maintenance page by setting the \
30
+ :maintenance_template_path variable in your deploy.rb file. The template file \
31
+ should either be a plaintext or an erb file.
32
+
33
+ Further customization will require that you write your own task.
34
+ DESC
35
+ task :disable, :roles => :web, :except => { :no_release => true } do
36
+ 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
62
+
63
+ reason = ENV['REASON']
64
+ deadline = ENV['UNTIL']
65
+
66
+ template = File.read(maintenance_template_path)
67
+ result = ERB.new(template).result(binding)
68
+
69
+ put result, "#{shared_path}/system/#{maintenance_basename}.html", :mode => 0644
70
+ end
71
+
72
+ desc <<-DESC
73
+ Makes the application web-accessible again. Removes the \
74
+ "#{maintenance_basename}.html" page generated by deploy:web:disable, which (if your \
75
+ web servers are configured correctly) will make your application \
76
+ web-accessible again.
77
+ DESC
78
+ task :enable, :roles => :web, :except => { :no_release => true } do
79
+ run "rm -f #{shared_path}/system/#{maintenance_basename}.html"
80
+ end
81
+
82
+ end
83
+
84
+ end
85
+
86
+ end
87
+
88
+ end
89
+
90
+ end
91
+
92
+ if Capistrano::Configuration.instance
93
+ Capistrano::Maintenance.load_into(Capistrano::Configuration.instance)
94
+ end
@@ -0,0 +1,3 @@
1
+ module Capistrano::Maintenance
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,53 @@
1
+
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4
+
5
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
6
+
7
+ <head>
8
+ <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
9
+ <title>System down for maintenance</title>
10
+
11
+ <style type="text/css">
12
+ div.outer {
13
+ position: absolute;
14
+ left: 50%;
15
+ top: 50%;
16
+ width: 500px;
17
+ height: 300px;
18
+ margin-left: -260px;
19
+ margin-top: -150px;
20
+ }
21
+
22
+ .DialogBody {
23
+ margin: 0;
24
+ padding: 10px;
25
+ text-align: left;
26
+ border: 1px solid #ccc;
27
+ border-right: 1px solid #999;
28
+ border-bottom: 1px solid #999;
29
+ background-color: #fff;
30
+ }
31
+
32
+ body { background-color: #fff; }
33
+ </style>
34
+ </head>
35
+
36
+ <body>
37
+
38
+ <div class="outer">
39
+ <div class="DialogBody" style="text-align: center;">
40
+ <div style="text-align: center; width: 200px; margin: 0 auto;">
41
+ <p style="color: red; font-size: 16px; line-height: 20px;">
42
+ The system is down for <%= reason ? reason : "maintenance" %>
43
+ as of <%= Time.now.strftime("%H:%M %Z") %>.
44
+ </p>
45
+ <p style="color: #666;">
46
+ It'll be back <%= deadline ? deadline : "shortly" %>.
47
+ </p>
48
+ </div>
49
+ </div>
50
+ </div>
51
+
52
+ </body>
53
+ </html>
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-maintenance
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Thomas von Deyen
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-29 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: capistrano
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 2.0.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 2.0.0
30
+ description: The deploy:web tasks where removed from Capistrano core. This extension
31
+ brings them back.
32
+ email: tvd@magiclabs.de
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - .gitignore
38
+ - README.md
39
+ - capistrano-maintenance.gemspec
40
+ - lib/capistrano/maintenance.rb
41
+ - lib/capistrano/maintenance/version.rb
42
+ - lib/capistrano/templates/maintenance.html.erb
43
+ homepage: https://github.com/tvdeyen/capistrano-maintenance
44
+ licenses:
45
+ - MIT
46
+ post_install_message:
47
+ rdoc_options: []
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ requirements: []
63
+ rubyforge_project:
64
+ rubygems_version: 1.8.24
65
+ signing_key:
66
+ specification_version: 3
67
+ summary: Offers deploy:web:disable and deploy:web:enable tasks for Capistrano.
68
+ test_files: []
69
+ has_rdoc: