We have a setup where nginx sits in front of 2 thin servers, and during deploys restarts the one on port 9000, then restarts the one on port 9001. We are using the onebyone option and driving the deploy with capistrano. It appears that what happens is thin stops the 9000 server, starts the 9000 server, and then as soon as it can get a socket moves on and takes down the 9001. Unfortunately it seems like there is some gap in between being able to get a socket (https://github.com/macournoyer/thin/blob/a7d1174f47a4491a15b505407c0501cdc8d8d12c/lib/thin/controllers/cluster.rb#L82
) and being responsive as an app server (maybe this is the rails environment loading?). This results in both of our servers being nonresponse at once and causes nginx to serve 502s for about 2-300ms during deploys.
Here is our server config:
1. Is there something obvious we are doing wrong?
2. Is there some way to add a few seconds pause before taking down the next server?
3. If we were able to find a more reliable way to determine if a rails server was responsive would you be interested in a patch?