diff --git a/CHANGELOG.md b/CHANGELOG.md index b13a545..fdc6ffb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Changelog for easy-deployment +## 0.6.2 (2015-11-10) + +Enhancements: + +* Add support for maintenance mode using the `turnout` gem. + +## 0.6.1 (2014-05-23) + +Minor changes: + +* Update reference data load to use the new rake task from `easy-reference` gem + ## 0.6.0 (2013-11-05) Features: @@ -9,7 +21,7 @@ Features: Bugfixes: -* Using builting `easy-reference` gem support now works with a custom bundler path if set. +* Using built-in `easy-reference` gem support now works with a custom bundler path if set. ## 0.5.3 (2013-09-05) diff --git a/README.md b/README.md index 96a2c66..f49e8f1 100644 --- a/README.md +++ b/README.md @@ -99,12 +99,20 @@ The created backup configuration will be scheduled on deploy to run nightly via 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. 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. -### Whenever +### Maintenance -If you use the whenever gem to manage application crontabs, automatically include the capistrano -hooks to run whenever each deploy via: +This includes a generator to create a maintenance mode configuration (generator is run by itself as `rails generate easy:maintenace`) + +This will generate: + + config/initializers/maintenace.rb + public/maintenance.html + public/maintenance.json + +Customise the site configuration within `config/initializers/maintenace.rb` to change the maintenance message, response status etc. +Customise the maintenance page within `public/maintenance.html` +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. - require "easy/deployment/whenever" ## Contributing diff --git a/easy-deployment.gemspec b/easy-deployment.gemspec index 9c05c42..94166aa 100644 --- a/easy-deployment.gemspec +++ b/easy-deployment.gemspec @@ -2,8 +2,8 @@ require File.expand_path('../lib/easy-deployment/version', __FILE__) Gem::Specification.new do |gem| - gem.authors = ["Jeremy Olliver", "Nigel Ramsay", "Shevaun Coker", "Cameron Fowler"] - gem.email = ["jeremy.olliver@abletech.co.nz", "nigel.ramsay@abletech.co.nz", "shevaun.coker@abletech.co.nz", "cameron.fowler@abletech.co.nz"] + gem.authors = ["Jeremy Olliver", "Nigel Ramsay", "Shevaun Coker", "Cameron Fowler", "Joseph Leniston"] + gem.email = ["jeremy.olliver@abletech.co.nz", "nigel.ramsay@abletech.co.nz", "shevaun.coker@abletech.co.nz", "cameron.fowler@abletech.co.nz", "joseph.leniston@abletech.co.nz"] gem.description = %q{Easy deployment: includes a generator, and capistrano configuration} gem.summary = %q{Gem for encapsulating Abletech's deployment practices} gem.homepage = "https://github.com/AbleTech/easy-deployment" @@ -17,7 +17,7 @@ Gem::Specification.new do |gem| gem.license = "GPLv3" gem.add_runtime_dependency 'rails', '>= 3.0.0' - gem.add_runtime_dependency 'capistrano', '~> 2.13.5' + gem.add_runtime_dependency 'capistrano', '>= 2.15' gem.add_development_dependency 'bundler' gem.add_development_dependency 'rspec', '~> 2.0' diff --git a/lib/easy-deployment.rb b/lib/easy-deployment.rb index c8d0953..47a6d71 100644 --- a/lib/easy-deployment.rb +++ b/lib/easy-deployment.rb @@ -1,5 +1,6 @@ require "easy-deployment/version" -require "easy/generators/generator_helpers" +require 'easy/generators/backup_generator' require 'easy/generators/deployment_generator' +require "easy/generators/generator_helpers" +require 'easy/generators/maintenance_generator' require 'easy/generators/stage_generator' -require 'easy/generators/backup_generator' diff --git a/lib/easy-deployment/version.rb b/lib/easy-deployment/version.rb index 0c142c9..043e386 100644 --- a/lib/easy-deployment/version.rb +++ b/lib/easy-deployment/version.rb @@ -1,5 +1,5 @@ module Easy module Deployment - VERSION = "0.6.1" + VERSION = "0.6.2" end end diff --git a/lib/easy/deployment/maintenance.rb b/lib/easy/deployment/maintenance.rb new file mode 100644 index 0000000..28e0984 --- /dev/null +++ b/lib/easy/deployment/maintenance.rb @@ -0,0 +1,19 @@ +# Define a capistrano task for putting the site into maintenance mode using +# turnout rack middleware. +# To load this capistrano configuration, require 'easy/deployment/maintenance' from deploy.rb +# +Capistrano::Configuration.instance(:must_exist).load do + + namespace :maintenance do + desc "Put the application into maintenance mode" + task :start, :roles => :app do + run "cd #{current_path} && RAILS_ENV=#{rails_env} bundle exec rake maintenance:start" + end + + desc "Take the application out of maintenance mode" + task :end, :roles => :app do + run "cd #{current_path} && RAILS_ENV=#{rails_env} bundle exec rake maintenance:end" + end + end + +end diff --git a/lib/easy/generators/backup_generator.rb b/lib/easy/generators/backup_generator.rb index ddc0c1b..97fd981 100644 --- a/lib/easy/generators/backup_generator.rb +++ b/lib/easy/generators/backup_generator.rb @@ -1,4 +1,5 @@ require 'rails/generators' +require "easy/generators/generator_helpers" module Easy class BackupGenerator < Rails::Generators::Base diff --git a/lib/easy/generators/deployment_generator.rb b/lib/easy/generators/deployment_generator.rb index e95a6a6..41b78cf 100644 --- a/lib/easy/generators/deployment_generator.rb +++ b/lib/easy/generators/deployment_generator.rb @@ -1,4 +1,5 @@ require 'rails/generators' +require "easy/generators/generator_helpers" module Easy class DeploymentGenerator < Rails::Generators::Base diff --git a/lib/easy/generators/maintenance_generator.rb b/lib/easy/generators/maintenance_generator.rb new file mode 100644 index 0000000..64603bf --- /dev/null +++ b/lib/easy/generators/maintenance_generator.rb @@ -0,0 +1,28 @@ +require 'rails/generators' + +module Easy + class MaintenanceGenerator < Rails::Generators::Base + source_root File.join(File.dirname(__FILE__), "templates") # Where templates are copied from + + desc %{Generates a maintenance config to allow you to put your application into maintenance mode} + + def create_maintenance_files + gem_group(:development) do + gem 'turnout', '~> 2.2' + end + + template("maintenance.rb.tt", "config/initializers/maintenance.rb") + template("maintenance.html.tt", "public/maintenance.html") + template("maintenance.json.tt", "public/maintenance.json") + + run("bundle install") + + say("Maintenance configuration generated", :green) + say(" - TODO: edit config/maintenance.rb setting default_maintenance_page, default_reason and other configuration options", :green) + say(" - TODO: edit public/maintenance.html to match site styles", :green) + + true + end + + end +end diff --git a/lib/easy/generators/templates/maintenance.html.tt b/lib/easy/generators/templates/maintenance.html.tt new file mode 100644 index 0000000..8cbd3b2 --- /dev/null +++ b/lib/easy/generators/templates/maintenance.html.tt @@ -0,0 +1,69 @@ + + +
+ +