Rainbows! Rack HTTP server user/dev discussion
 help / color / mirror / code / Atom feed
From: Eric Wong <normalperson-rMlxZR9MS24@public.gmane.org>
To: Rainbows! list <rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org>
Subject: Re: graceful shutdown
Date: Sun, 1 May 2011 21:51:36 +0000	[thread overview]
Message-ID: <20110501215136.GC13274@dcvr.yhbt.net> (raw)
In-Reply-To: <BANLkTimZtpKWjyRa0M9habiw1npXdMkUBQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

Mike Perham <mperham-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> I've got a multithreaded system, some threads are responding to web
> requests, others are performing background/async tasks.  Is there any
> way to implement graceful shutdown with Rainbows?  Currently I have a
> blocking SIGQUIT shutdown hook for my async task library:
> https://github.com/mperham/girl_friday/blob/master/lib/girl_friday.rb#L55
> Will this work? Is this all that's really needed?

No, install an at_exit block instead.

Rainbows! itself relies on SIGQUIT for graceful shutdown, so your trap
would conflict with that.

There are some caveats since Rainbows! won't wait forever for graceful
shutdowns, either.

The Unicorn/Rainbows! master process defaults the "timeout"[1] parameter
to 60s.  If an at_exit handler takes a long time, increase the "timeout"

The "timeout" directive affects how long the master process will wait
for a worker process to gracefully exit after a SIQQUIT is sent.  If the
timeout expires after SIGQUIT, the master will assume the worker is
non-responsive/stuck and send a SIGKILL to finish the worker off.

By definition of a graceful shutdown, Rainbows! will also try to wait
until all currently running requests are complete, too[2].  Having a
long keepalive_timeout (default is only 5s) also affects the time it
takes to shutdown[3].

[1] http://unicorn.bogomips.org/Unicorn/Configurator.html#method-i-timeout
[2] this is a huge pain for infinite endpoints like
    http://raindrops-demo.bogomips.org/tail/ :<
[3] It's not consistent across concurrency options right now and
    not easy to fix consistently.

Eric Wong
Rainbows! mailing list - rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
Do not quote signatures (like this one) or top post when replying

      parent reply	other threads:[~2011-05-01 21:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-01 20:52 graceful shutdown Mike Perham
     [not found] ` <BANLkTimZtpKWjyRa0M9habiw1npXdMkUBQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-05-01 21:51   ` Eric Wong [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://yhbt.net/rainbows/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110501215136.GC13274@dcvr.yhbt.net \
    --to=normalperson-rmlxzr9ms24@public.gmane.org \
    --cc=rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).