Skip to content
Browse files

New variable "maintenance_basename" to set maintenance file basename

  • Loading branch information...
1 parent cb70695 commit 0c45e4ab94d2a038aa398215b5bd773d47733db5 @tinogomes tinogomes committed Nov 24, 2010
Showing with 13 additions and 10 deletions.
  1. +13 −10 lib/capistrano/recipes/deploy.rb
View
23 lib/capistrano/recipes/deploy.rb
@@ -28,6 +28,9 @@ def _cset(name, *args, &block)
_cset(:deploy_to) { "/u/apps/#{application}" }
_cset(:revision) { source.head }
+# Maintenance base filename
+_cset :maintenance_basename, "maintenance"
+
# =========================================================================
# These variables should NOT be changed unless you are very confident in
# what you are doing. Make sure you understand all the implications of your
@@ -542,7 +545,7 @@ def try_runner(*args)
namespace :web do
desc <<-DESC
Present a maintenance page to visitors. Disables your application's web \
- interface by writing a "maintenance.html" file to each web server. The \
+ interface by writing a "#{maintenance_basename}.html" file to each web server. The \
servers must be configured to detect the presence of this file, and if \
it is present, always display it instead of performing the request.
@@ -558,18 +561,18 @@ def try_runner(*args)
DESC
task :disable, :roles => :web, :except => { :no_release => true } do
require 'erb'
- on_rollback { run "rm #{shared_path}/system/maintenance.html" }
+ on_rollback { run "rm #{shared_path}/system/#{maintenance_basename}.html" }
warn <<-EOHTACCESS
-
+
# Please add something like this to your site's 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.html
+
+ ErrorDocument 503 /system/#{maintenance_basename}.html
RewriteEngine On
RewriteCond %{REQUEST_URI} !\.(css|gif|jpg|png)$
- RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
- RewriteCond %{SCRIPT_FILENAME} !maintenance.html
+ RewriteCond %{DOCUMENT_ROOT}/system/#{maintenance_basename}.html -f
+ RewriteCond %{SCRIPT_FILENAME} !#{maintenance_basename}.html
RewriteRule ^.*$ - [redirect=503,last]
EOHTACCESS
@@ -579,17 +582,17 @@ def try_runner(*args)
template = File.read(File.join(File.dirname(__FILE__), "templates", "maintenance.rhtml"))
result = ERB.new(template).result(binding)
- put result, "#{shared_path}/system/maintenance.html", :mode => 0644
+ put result, "#{shared_path}/system/#{maintenance_basename}.html", :mode => 0644
end
desc <<-DESC
Makes the application web-accessible again. Removes the \
- "maintenance.html" page generated by deploy:web:disable, which (if your \
+ "#{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 #{shared_path}/system/maintenance.html"
+ run "rm #{shared_path}/system/#{maintenance_basename}.html"
end
end
end

0 comments on commit 0c45e4a

Please sign in to comment.
Something went wrong with that request. Please try again.