cap deploy:web:enable

written by justin on March 3rd, 2009 @ 11:41 AM

I have finally decided to start putting up a warning page when doing maintenance on one of my sites. I decided that I wanted to use capistrano to get the job done. I checked the cap -T task list and noticed that there was already one there. It was pretty bleak looking so I decided to just roll my own page and put up a task to change the filename when needed and it would be picked up by nginx and displayed. I made up a page and put in on my production server under the system folder in the shared path and named it m.html. I then wrote up a couple of cap tasks to manage the renaming of the file and put them into my deploy.rb file:

desc "Turn on Maintenance Mode"
task :maint_on, :hosts => @web do
  run "mv #{shared_path}/system/m.html #{shared_path}/system/maintenance.html"
end

desc "Turn off Maintenance Mode"
task :maint_off, :hosts => @web do
  run "mv #{shared_path}/system/maintenance.html #{shared_path}/system/m.html"
end

disclaimer: there is probably already a way to do this using the original deploy:web:enable, but I didn't want to figure it out.

Post a comment