From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: * X-Spam-ASN: AS14383 205.234.109.0/24 X-Spam-Status: No, score=1.0 required=3.0 tests=AWL,HK_RANDOM_FROM, MSGID_FROM_MTA_HEADER shortcircuit=no autolearn=no version=3.3.2 Path: news.gmane.org!not-for-mail From: Eric Wong Newsgroups: gmane.comp.lang.ruby.rainbows.general Subject: Re: graceful shutdown Date: Sun, 1 May 2011 21:51:36 +0000 Message-ID: <20110501215136.GC13274@dcvr.yhbt.net> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1304286746 22641 80.91.229.12 (1 May 2011 21:52:26 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 1 May 2011 21:52:26 +0000 (UTC) To: Rainbows! list Original-X-From: rainbows-talk-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Sun May 01 23:52:22 2011 Return-path: Envelope-to: gclrrg-rainbows-talk@m.gmane.org X-Original-To: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Delivered-To: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) X-BeenThere: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: rainbows-talk-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Errors-To: rainbows-talk-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Xref: news.gmane.org gmane.comp.lang.ruby.rainbows.general:244 Archived-At: Received: from rubyforge.org ([205.234.109.19]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QGeYv-0005XW-96 for gclrrg-rainbows-talk@m.gmane.org; Sun, 01 May 2011 23:52:21 +0200 Received: from rubyforge.org (rubyforge.org [127.0.0.1]) by rubyforge.org (Postfix) with ESMTP id 2C57E18582EE; Sun, 1 May 2011 17:52:20 -0400 (EDT) Received: from dcvr.yhbt.net (dcvr.yhbt.net [64.71.152.64]) by rubyforge.org (Postfix) with ESMTP id 948231858112 for ; Sun, 1 May 2011 17:51:36 -0400 (EDT) Received: from localhost (unknown [127.0.2.5]) by dcvr.yhbt.net (Postfix) with ESMTP id 7738E1FD59; Sun, 1 May 2011 21:51:36 +0000 (UTC) Mike Perham 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" directive. 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/0.0.0.0%3A80.txt :< [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 http://rubyforge.org/mailman/listinfo/rainbows-talk Do not quote signatures (like this one) or top post when replying