I believe what's missing here is that thin is the process receiving the
sigterm, and doesn't respond correctly.  Instead of using sigterm as a
notice to quit when it can, it treats sigterm as a -9 equivalent.  This is a
bug in older versions of thin.  We've worked with the thin maintainers to
get this fixed, and the newest versions do now handle sigterm correctly.

If you are on bamboo, you can put thin in your gemfile on the latest version
(1.2.11) and you'll get the correct behavior responding to signals.  However
there are dependencies between older versions of ruby and older versions of
thin, so if you aren't running the latest rails, you may not be able to use
the latest thin.  This is why we haven't deployed it by default to all apps.

Yes, we need to document this better.  Sorry about the confusion.

Oren

On Thu, May 12, 2011 at 1:11 PM, midwaltz <[email protected]> wrote:

> Interesting, thanks Peter. Yes, that's probably worth documenting.
>
> Two questions:
>
> - Are requests in the queue somehow pre-assigned to a specific dyno?
> I'm asking because I'm testing this behavior on a bare sinatra app
> with a get handler that sleeps for 0.5 seconds and then returns 'OK'.
> In other words the request takes half a second, so according to you it
> should be quick enough to finish before being sent a SIGKILL. But I
> keep seeing those errors, so I'm guessing either Sinatra panics and
> kills itself on SIGTERM, or maybe it's a queue thing? I'll be happy to
> share the code I'm using to make the tests if you'd like. (I'm using
> the default Sinatra gem (not specifying a version) on the bamboo-
> ree-1.8.7 stack).
>
> - How do I catch a SIGTERM during a Sinatra app request?
>
>
>
>
>
>
> On May 12, 10:15 am, Peter van Hardenberg <[email protected]> wrote:
> > We normally send a SIGTERM, then wait five (ish?) seconds to let the last
> > request serve and then, then send SIGKILL if the process still hasn't
> gone
> > away.
> >
> > You can confirm this behaviour here by catching and logging the SIGTERM
> in
> > your app and then reproducing the situation you describe. If you can
> provide
> > a test-case that shows you're not seeing expected behaviour (I use it
> > extensively in one of my test apps) I'll make a ticket gets filed against
> > the Runtime. Otherwise, maybe there's somewhere we can improve our
> > documentation here.
> >
> > Regards,
> >
> > Peter
> > Heroku
> >
> >
> >
> >
> >
> >
> >
> > On Wed, May 11, 2011 at 8:49 PM, midwaltz <[email protected]> wrote:
> >
> > > When decreasing Dynos while they are busy, some of them return a 503
> > > status error with Heroku error code H13 (Connection closed without
> > > response
> > >http://devcenter.heroku.com/articles/error-codes#h13__connection_clos.
> ..
> > > ).
> >
> > > I can only speculate, but to me it looks like instead of waiting for
> > > the Dyno to finish sending its request, the Dyno is killed right away.
> >
> > > After a quick Googling I found out this bug might have been known for
> > > a while:
> > >http://www.continuousthinking.com/2010/11/3/heroku-autoscaling-bug
> > > (except the error status codes look different, but it might have been
> > > a misstep?).
> >
> > > What's the status on fixing this bug?
> >
> > > Cheers,
> > > Steph
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Heroku" group.
> > > To post to this group, send email to [email protected].
> > > To unsubscribe from this group, send email to
> > > [email protected].
> > > For more options, visit this group at
> > >http://groups.google.com/group/heroku?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Heroku" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/heroku?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Heroku" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/heroku?hl=en.

Reply via email to