Skip to content

Commit 689ccd0

Browse files
author
James
committed
Merge pull request #11 from AbleTech/feature/maintenance
Add support for maintenance mode. Bump version
2 parents df342db + dc3da50 commit 689ccd0

File tree

12 files changed

+169
-11
lines changed

12 files changed

+169
-11
lines changed

CHANGELOG.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Changelog for easy-deployment
22

3+
## 0.6.2 (2015-11-10)
4+
5+
Enhancements:
6+
7+
* Add support for maintenance mode using the `turnout` gem.
8+
9+
## 0.6.1 (2014-05-23)
10+
11+
Minor changes:
12+
13+
* Update reference data load to use the new rake task from `easy-reference` gem
14+
315
## 0.6.0 (2013-11-05)
416

517
Features:
@@ -9,7 +21,7 @@ Features:
921

1022
Bugfixes:
1123

12-
* Using builting `easy-reference` gem support now works with a custom bundler path if set.
24+
* Using built-in `easy-reference` gem support now works with a custom bundler path if set.
1325

1426
## 0.5.3 (2013-09-05)
1527

README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,20 @@ The created backup configuration will be scheduled on deploy to run nightly via
9999
The default setup is to backup the capistrano system folder, the configured database, to store the backup in S3, and notify of failures via email.
100100
All these settings are configurable, to read more see the documentation for the backup gem https://github.com/meskyanichi/backup and setup your configuration to suit yourself.
101101

102-
### Whenever
102+
### Maintenance
103103

104-
If you use the whenever gem to manage application crontabs, automatically include the capistrano
105-
hooks to run whenever each deploy via:
104+
This includes a generator to create a maintenance mode configuration (generator is run by itself as `rails generate easy:maintenace`)
105+
106+
This will generate:
107+
108+
config/initializers/maintenace.rb
109+
public/maintenance.html
110+
public/maintenance.json
111+
112+
Customise the site configuration within `config/initializers/maintenace.rb` to change the maintenance message, response status etc.
113+
Customise the maintenance page within `public/maintenance.html`
114+
All these settings are configurable, to read more see the documentation for the turnout gem https://github.com/biola/turnout and setup your configuration to suit yourself.
106115

107-
require "easy/deployment/whenever"
108116

109117
## Contributing
110118

easy-deployment.gemspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
require File.expand_path('../lib/easy-deployment/version', __FILE__)
33

44
Gem::Specification.new do |gem|
5-
gem.authors = ["Jeremy Olliver", "Nigel Ramsay", "Shevaun Coker", "Cameron Fowler"]
6-
5+
gem.authors = ["Jeremy Olliver", "Nigel Ramsay", "Shevaun Coker", "Cameron Fowler", "Joseph Leniston"]
6+
77
gem.description = %q{Easy deployment: includes a generator, and capistrano configuration}
88
gem.summary = %q{Gem for encapsulating Abletech's deployment practices}
99
gem.homepage = "https://github.com/AbleTech/easy-deployment"
@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
1717
gem.license = "GPLv3"
1818

1919
gem.add_runtime_dependency 'rails', '>= 3.0.0'
20-
gem.add_runtime_dependency 'capistrano', '~> 2.13.5'
20+
gem.add_runtime_dependency 'capistrano', '>= 2.15'
2121

2222
gem.add_development_dependency 'bundler'
2323
gem.add_development_dependency 'rspec', '~> 2.0'

lib/easy-deployment.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
require "easy-deployment/version"
2-
require "easy/generators/generator_helpers"
2+
require 'easy/generators/backup_generator'
33
require 'easy/generators/deployment_generator'
4+
require "easy/generators/generator_helpers"
5+
require 'easy/generators/maintenance_generator'
46
require 'easy/generators/stage_generator'
5-
require 'easy/generators/backup_generator'

lib/easy-deployment/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module Easy
22
module Deployment
3-
VERSION = "0.6.1"
3+
VERSION = "0.6.2"
44
end
55
end

lib/easy/deployment/maintenance.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Define a capistrano task for putting the site into maintenance mode using
2+
# turnout rack middleware.
3+
# To load this capistrano configuration, require 'easy/deployment/maintenance' from deploy.rb
4+
#
5+
Capistrano::Configuration.instance(:must_exist).load do
6+
7+
namespace :maintenance do
8+
desc "Put the application into maintenance mode"
9+
task :start, :roles => :app do
10+
run "cd #{current_path} && RAILS_ENV=#{rails_env} bundle exec rake maintenance:start"
11+
end
12+
13+
desc "Take the application out of maintenance mode"
14+
task :end, :roles => :app do
15+
run "cd #{current_path} && RAILS_ENV=#{rails_env} bundle exec rake maintenance:end"
16+
end
17+
end
18+
19+
end

lib/easy/generators/backup_generator.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require 'rails/generators'
2+
require "easy/generators/generator_helpers"
23

34
module Easy
45
class BackupGenerator < Rails::Generators::Base

lib/easy/generators/deployment_generator.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require 'rails/generators'
2+
require "easy/generators/generator_helpers"
23

34
module Easy
45
class DeploymentGenerator < Rails::Generators::Base
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
require 'rails/generators'
2+
3+
module Easy
4+
class MaintenanceGenerator < Rails::Generators::Base
5+
source_root File.join(File.dirname(__FILE__), "templates") # Where templates are copied from
6+
7+
desc %{Generates a maintenance config to allow you to put your application into maintenance mode}
8+
9+
def create_maintenance_files
10+
gem_group(:development) do
11+
gem 'turnout', '~> 2.2'
12+
end
13+
14+
template("maintenance.rb.tt", "config/initializers/maintenance.rb")
15+
template("maintenance.html.tt", "public/maintenance.html")
16+
template("maintenance.json.tt", "public/maintenance.json")
17+
18+
run("bundle install")
19+
20+
say("Maintenance configuration generated", :green)
21+
say(" - TODO: edit config/maintenance.rb setting default_maintenance_page, default_reason and other configuration options", :green)
22+
say(" - TODO: edit public/maintenance.html to match site styles", :green)
23+
24+
true
25+
end
26+
27+
end
28+
end
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Down for Maintenance</title>
6+
7+
<style type="text/css">
8+
9+
*{
10+
font-family: Arial, Helvetica, sans-serif;
11+
}
12+
13+
body{
14+
margin: 0;
15+
background-color: #fff;
16+
}
17+
18+
#page{
19+
position: relative;
20+
width: 550px;
21+
margin: 200px auto;
22+
padding: 75px 0;
23+
text-align: center;
24+
background-color: #eaeaea;
25+
border: solid 1px #ccc;
26+
border-top: solid 10px #666;
27+
-moz-box-shadow: inset 0 2px 10px #ccc;
28+
-webkit-box-shadow: inset 0 2px 10px #ccc;
29+
box-shadow: inset 0 2px 10px #ccc;
30+
}
31+
32+
header, #body{
33+
width: 400px;
34+
margin: 0 auto;
35+
}
36+
37+
h1{
38+
margin: 0;
39+
color: #CC3601;
40+
font-size: 26pt;
41+
border-bottom: solid 4px #666;
42+
}
43+
44+
#reason{
45+
margin: 10px 0;
46+
color: #333;
47+
}
48+
49+
</style>
50+
51+
</head>
52+
<body>
53+
54+
<section id="page">
55+
56+
<header>
57+
<h1>Down for Maintenance</h1>
58+
</header>
59+
60+
<section id="body">
61+
<div>
62+
{{ reason }}
63+
</div>
64+
</section>
65+
66+
</section>
67+
68+
</body>
69+
</html>

0 commit comments

Comments
 (0)