lib/capistrano/maintenance.rb in capistrano-maintenance-0.0.2 vs lib/capistrano/maintenance.rb in capistrano-maintenance-0.0.3
- old
+ new
@@ -3,10 +3,11 @@
module Capistrano::Maintenance
def self.load_into(configuration)
configuration.load do
+ _cset(:maintenance_dirname) { "#{shared_path}/system" }
_cset :maintenance_basename, "maintenance"
_cset(:maintenance_template_path) { File.join(File.dirname(__FILE__), "templates", "maintenance.html.erb") }
namespace :deploy do
@@ -32,52 +33,54 @@
Further customization will require that you write your own task.
DESC
task :disable, :roles => :web, :except => { :no_release => true } do
require 'erb'
- on_rollback { run "rm -f #{shared_path}/system/#{maintenance_basename}.html" }
+ on_rollback { run "rm -f #{mainteannce_dirname}/#{maintenance_basename}.html" }
- warn <<-EOHTACCESS
+ if fetch(:maintenance_config_warning, true)
+ warn <<-EOHTACCESS
- # Please add something like this to your site's Apache htaccess to redirect users to the maintenance page.
- # More Info: http://www.shiftcommathree.com/articles/make-your-rails-maintenance-page-respond-with-a-503
+ # Please add something like this to your site's Apache htaccess to redirect users to the maintenance page.
+ # More Info: http://www.shiftcommathree.com/articles/make-your-rails-maintenance-page-respond-with-a-503
- ErrorDocument 503 /system/#{maintenance_basename}.html
- RewriteEngine On
- RewriteCond %{REQUEST_URI} !\.(css|gif|jpg|png)$
- RewriteCond %{DOCUMENT_ROOT}/system/#{maintenance_basename}.html -f
- RewriteCond %{SCRIPT_FILENAME} !#{maintenance_basename}.html
- RewriteRule ^.*$ - [redirect=503,last]
+ ErrorDocument 503 /system/#{maintenance_basename}.html
+ RewriteEngine On
+ RewriteCond %{REQUEST_URI} !\.(css|gif|jpg|png)$
+ RewriteCond %{DOCUMENT_ROOT}/system/#{maintenance_basename}.html -f
+ RewriteCond %{SCRIPT_FILENAME} !#{maintenance_basename}.html
+ RewriteRule ^.*$ - [redirect=503,last]
- # Or if you are using Nginx add this to your server config:
+ # Or if you are using Nginx add this to your server config:
- if (-f $document_root/system/maintenance.html) {
- return 503;
- }
- error_page 503 @maintenance;
- location @maintenance {
- rewrite ^(.*)$ /system/maintenance.html last;
- break;
- }
- EOHTACCESS
+ if (-f $document_root/system/maintenance.html) {
+ return 503;
+ }
+ error_page 503 @maintenance;
+ location @maintenance {
+ rewrite ^(.*)$ /system/maintenance.html last;
+ break;
+ }
+ EOHTACCESS
+ end
reason = ENV['REASON']
deadline = ENV['UNTIL']
template = File.read(maintenance_template_path)
result = ERB.new(template).result(binding)
- put result, "#{shared_path}/system/#{maintenance_basename}.html", :mode => 0644
+ put result, "#{maintenance_dirname}/#{maintenance_basename}.html", :mode => 0644
end
desc <<-DESC
Makes the application web-accessible again. Removes the \
"#{maintenance_basename}.html" page generated by deploy:web:disable, which (if your \
web servers are configured correctly) will make your application \
web-accessible again.
DESC
task :enable, :roles => :web, :except => { :no_release => true } do
- run "rm -f #{shared_path}/system/#{maintenance_basename}.html"
+ run "rm -f #{maintenance_dirname}/#{maintenance_basename}.html"
end
end
end