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).
Changes here from @davejamesmiller's version is that I DO NOT use a special /ping url, I want to test ACTUAL work being done, i.e. my homepage will probably crash if the DB isn't connecting, Elasticsearch doesn't connect, other needed configs...
Further fixes I'd like to do is to test the response of the curl. So, that if I get a 404, or a 500, then I kind of want my capistrano deploy to alert me with a failure? Otherwise, deploys typically work just fine, so I'm happy for now with the app being warmed up, hot&ready, like pizza to go.