So I am using Capistrano to deploy a rails application to my production server (apache+passenger) and at the moment deployment usually goes along the lines:
$cap deploy
$cap deploy:migrations
It got me wondering, let's say my db:migrations took a long time to execute on the production server (a big refactor of the db schema) – in this case what is best practice with Capistrano? What happens if users are connected to my application at the time of deployment? Should I gracefully send users to a static placeholder page while the database is being updated? Does Capistrano handle this automagically? Do I need to code up a recipe to help with this? Or does the internal mechanisms of rails / passenger mean that I don't have to worry at all about this particular case?
Thanks.
Best Answer
You should put up a maintenance page if the application is not going to be available for a while. I use this Capistrano task:
The
app/views/admin/maintenance.html.erb
file should contain:The final step is to configure the Apache virtual host with some directives to look for the
maintenance.html
file and redirect all requests to it if it's present:To put the application into maintenance mode, run
cap deploy:web:disable
and to make it live again docap deploy:web:enable
.