Skip to content

Instantly share code, notes, and snippets.

View peterdietz's full-sized avatar

Peter Dietz peterdietz

View GitHub Profile
@peterdietz
peterdietz / README.md
Last active September 7, 2015 02:26
Capistrano3 + Rails4 + NGINX + Passenger. After cap deploy restarts the app, we want to warm it up with a ping, so end user never waits

Most instructions for using Capistrano tell you how to make it restart Phusion Passenger by 'touch'ing the restart.txt file, but this doesn't immediately restart the app - instead the first person to try to use the application will cause it to be restarted, so they will see a delay of at least a few seconds.

This shows how to add a post-deploy task to 'ping' the server, to cause it to restart immediately.

Then add a deploy:ping task to config/deploy.rb and set it to run automatically after deploy:restart. Alternatively you could put it into the deploy:restart task directly.

TODO: Test the response HTTP header of the ping, that it is a 200, and not some other error response (404/500).