Search code examples
ruby-on-railsruby-on-rails-3unicorn

Unable to gracefully shutdown unicorn server with QUIT


We're doing zero downtime deploys for our Rails app using unicorn and the usual zero downtime deploy setup. (we don't use the exact setup from the example, but the thing is similiar).

This used to work, but during our upgrade to Rails 3.2 we ran into a weird problem:

  • Old unicorn master gets USR2
  • New master is spawned
  • However, the old master does never terminate and does seem to react to QUIT at all.
  • The old master will still react to WINCH and shut down all workers, and it can be shut down with TERM - but graceful shutdown just doesn't work

We do attempt to close the database connection from the master processes, but are not completely if it does still hold Redis connections (and if that would cause a problem).


Solution

  • Just for the people who run into the some problem: Someone put this gist into our code, that cleverly trapped the QUIT signal... sigh. So it had nothing to do with the unicorn setup at all.