I recently learned that capistrano can temporarily take down the web server while it’s being updated. This sounded like a very good idea to me, so I’ve started to use it. The only change I needed to make was to my /etc/httpd/conf/httpd.conf file. My virtual host now looks like this:

<VirtualHost *:80>
  ServerName survey.example.com
  DocumentRoot /local/data1/web/app/hepsurvey/current/public
  ErrorDocument 503 /system/maintenance.html
  RewriteEngine On
  RewriteCond %{REQUEST_URI} !.(css|gif|jpg|png)$
  RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
  RewriteCond %{SCRIPT_FILENAME} !maintenance.html
  RewriteRule ^.*$  -  [redirect=503,last]
</VirtualHost>

Then, to update, I use these commands.

git status
git commit -a
git push --all
cap deploy:web:disable
cap deploy
cap deploy:web:enable