gregburek/heroku-buildpack-pgbouncer — pull request #20 by agriffis (2014-03-27 01:53:55+00:00)
Title: Overhaul to handle SIGTERM properly.

I found that our attempted top-level trap was preventing the app from receiving SIGTERM for orderly shutdown of the dyno. After some experimentation, here's what I came up with. See https://gist.github.com/agriffis/9798319 for my test script. (You can run it on the command-line with values for $1 and $2 to see how the overall manager behaves when processes die by various causes.)

I'm using this now on deployed servers.