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=-0.6 required=5.0 tests=AWL,MSGID_FROM_MTA_HEADER, NORMAL_HTTP_TO_IP,RP_MATCHES_RCVD shortcircuit=no autolearn=unavailable version=3.3.2 Path: news.gmane.org!not-for-mail From: Paul Sponagl Newsgroups: gmane.comp.lang.ruby.unicorn.general Subject: Re: Unicorn Date: Thu, 9 Jul 2009 10:06:03 +0200 Message-ID: <3D052B79-A43B-4A7C-9ED4-032B31CBE664@sponagl.de> References: <218F5913-4D49-4F6C-B334-CF264120D61A@sponagl.de> <20090706231646.GA22306@dcvr.yhbt.net> <20090707204839.GA2650@dcvr.yhbt.net> <20090708220413.GA32416@dcvr.yhbt.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v935.3) Content-Type: text/plain; charset="iso-8859-1"; Format="flowed"; DelSp="yes" Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1247126804 31046 80.91.229.12 (9 Jul 2009 08:06:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 9 Jul 2009 08:06:44 +0000 (UTC) Cc: mongrel-unicorn@rubyforge.org To: Eric Wong Original-X-From: mongrel-unicorn-bounces@rubyforge.org Thu Jul 09 10:06:37 2009 Return-path: Envelope-to: gclrug-mongrel-unicorn@m.gmane.org X-Original-To: mongrel-unicorn@rubyforge.org Delivered-To: mongrel-unicorn@rubyforge.org In-Reply-To: <20090708220413.GA32416@dcvr.yhbt.net> X-Mailer: Apple Mail (2.935.3) X-DSPAM-Result: Whitelisted X-DSPAM-Processed: Thu Jul 9 10:16:38 2009 X-DSPAM-Confidence: 0.9997 X-DSPAM-Probability: 0.0000 X-DSPAM-Signature: 4a55a7665173716248820 X-DSPAM-Factors: 27, She+Said, 0.00010, 0+codename, 0.00010, codename, 0.00010, That's+What, 0.00010, Said, 0.00010, What+She, 0.00010, codename+That's, 0.00010, thin+1, 0.00010, >+>, 0.00010, >+>, 0.00010, ActionController, 0.00011, ActionController, 0.00011, Paul+Sponagl, 0.00011, Received*83+236, 0.00014, Received*(port+83, 0.00015, Received*236+203, 0.00015, Received*[83.236.203.217]), 0.00015, Received*217.static.qsc.de, 0.00015, Received*203+217.static.qsc.de, 0.00015, Received*217.static.qsc.de+[83.236.203.217]), 0.00015, Mime-Version*Message+framework, 0.00016, Mime-Version*framework, 0.00016, Mime-Version*(Apple+Message, 0.00016, Mime-Version*(Apple, 0.00016, Mime-Version*1.0+(Apple, 0.00016, Mime-Version*Message, 0.00016, Received*ESMTPSA, 0.00017 X-BeenThere: mongrel-unicorn@rubyforge.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: mongrel-unicorn-bounces@rubyforge.org Errors-To: mongrel-unicorn-bounces@rubyforge.org Xref: news.gmane.org gmane.comp.lang.ruby.unicorn.general:6 Archived-At: Received: from rubyforge.org ([205.234.109.19]) by lo.gmane.org with esmtp (Exim 4.50) id 1MOoeJ-0001sY-KS for gclrug-mongrel-unicorn@m.gmane.org; Thu, 09 Jul 2009 10:06:35 +0200 Received: from rubyforge.org (rubyforge.org [127.0.0.1]) by rubyforge.org (Postfix) with ESMTP id 039261D780F1 for ; Thu, 9 Jul 2009 04:06:34 -0400 (EDT) Received: from mail.abracus.de (mail.abracus.de [88.198.54.80]) by rubyforge.org (Postfix) with ESMTP id 81AB41D780F1 for ; Thu, 9 Jul 2009 04:06:32 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.abracus.de (Postfix) with SMTP id 043BAFD40F0 for ; Thu, 9 Jul 2009 10:16:38 +0200 (CEST) Received: from [192.168.1.32] (port-83-236-203-217.static.qsc.de [83.236.203.217]) by mail.abracus.de (Postfix) with ESMTPSA id B3C85FD4054; Thu, 9 Jul 2009 10:16:34 +0200 (CEST) Eric - you're a genius ! This patch solved it! Indeed i am forking a sleeping cache refresh process at requests to = '/' via a system call. Now i am ready to give it a try. Thank you very much for your help! All the best for you and unicorn Paul PS: Last time i forgot to cc to the list - i added my previous mail = below to keep searchers- and engines happy. Am 09.07.2009 um 00:04 schrieb Eric Wong: > Paul Sponagl wrote: > > > >> hmmm - everything works as it should... > > Very odd, nothing out of the ordinary there. Is there any chance your > application forks/execs long-running processes in the background? I'm > relying on the FD_CLOEXEC flag to be inherited by accepted sockets = > from > the original listen socket. Maybe that's not the case with OSX... > > Perhaps this patch can fix things under OSX? > > diff --git a/lib/unicorn.rb b/lib/unicorn.rb > index 281aa7d..f3073f4 100644 > --- a/lib/unicorn.rb > +++ b/lib/unicorn.rb > @@ -444,6 +444,7 @@ module Unicorn > # once a client is accepted, it is processed in its entirety here > # in 3 easy steps: read request, call app, write app response > def process_client(app, client) > + client.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) > response =3D app.call(env =3D REQUEST.read(client)) > > if 100 =3D=3D response.first.to_i > >> i also tried this config.ru >> ---8<--- >> # config.ru >> require "config/environment" >> use Rack::Lint >> run ActionController::Dispatcher.new >> ---8<--- >> >> does this activate Rack::Lint ? > > Yes it should. > > Thanks for looking into this issue and doing detailed analysis > on it! > > -- = > Eric Wong > > = > > Hi Eric, ok, let me write down a few tests: unicorn_rails with static content: ------------------------------------------- Macintosh-2:> echo -n "7 bytes" > public/test.html Macintosh-2:> unicorn_rails I, [2009-07-08T09:46:53.445542 #25037] INFO -- : listening on = addr=3D0.0.0.0:8080 fd=3D3 I, [2009-07-08T09:46:53.647616 #25037] INFO -- : worker=3D0 spawning... I, [2009-07-08T09:46:53.648553 #25037] INFO -- : master process ready I, [2009-07-08T09:46:53.651324 #25039] INFO -- : worker=3D0 spawned = pid=3D25039 I, [2009-07-08T09:46:53.651812 #25039] INFO -- : Refreshing Gem list worker=3D0 ready Macintosh-2:~> telnet 127.0.0.1 8080 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. GET /test.html HTTP/1.1 Host: test.local HTTP/1.1 200 OK Date: Wed, 08 Jul 2009 07:47:33 GMT Status: 200 OK Connection: close Last-Modified: Wed, 08 Jul 2009 07:46:42 GMT Content-Type: text/html Content-Length: 7 7 bytesConnection closed by foreign host. Worked ... unicorn_rails with simple rails content: -------------------------------------------------- class HomeController < ApplicationController layout 'home' def test render :text =3D> '7 bytes' end Macintosh-2:~> telnet 127.0.0.1 8080 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. GET /home/test HTTP/1.1 Host: test.local HTTP/1.1 200 OK Date: Wed, 08 Jul 2009 07:50:23 GMT Status: 200 OK Connection: close X-Runtime: 2059 ETag: "4028bd3c2c4b2eec87994d1a46c86878" Content-Type: text/html; charset=3Dutf-8 Cache-Control: private, max-age=3D0, must-revalidate Content-Length: 7 Set-Cookie: flash=3D%7B%7D; path=3D/ Set-Cookie: _bilderbuch_session=3D...; path=3D/; HttpOnly 7 bytesConnection closed by foreign host. worked... thin with more complex rails content: -------------------------------------------------- Macintosh-2:~> wget --server-response http://127.0.0.1:8080/ --10:01:52-- http://127.0.0.1:8080/ =3D> `index.html.3' Verbindungsaufbau zu 127.0.0.1:8080... verbunden. HTTP Anforderung gesendet, warte auf Antwort... 1 HTTP/1.1 200 OK 2 X-Runtime: 446 3 ETag: "0eda35d2574d23011a57cff8043800c8" 4 Content-Type: text/html; charset=3Dutf-8 5 Cache-Control: private, max-age=3D0, must-revalidate 6 Set-Cookie: flash=3D%7B%7D; path=3D/ 7 Set-Cookie: _bilderbuch_session=3D...; path=3D/; HttpOnly 8 Content-Length: 24340 9 Connection: keep-alive 10 Server: thin 1.0.0 codename That's What She Said 100%[=3D=3D=3D=3D=3D=3D>] 24,340 23.21M/s ETA 00:00 10:01:53 (23.21 MB/s) - =BBindex.html.3=AB gespeichert [24340/24340] Macintosh-2:~> ls -la index.html.3 -rw-r--r-- 1 paulspon paulspon 24340 8. Jul 10:01 index.html.3 worked (content-length and filesize matches)... unicorn_rails with more complex rails content: ------------------------------------------------------------- Macintosh-2:~> wget --server-response http://127.0.0.1:8080/ --10:02:50-- http://127.0.0.1:8080/ =3D> `index.html.4' Verbindungsaufbau zu 127.0.0.1:8080... verbunden. HTTP Anforderung gesendet, warte auf Antwort... 1 HTTP/1.1 200 OK 2 Date: Wed, 08 Jul 2009 08:02:51 GMT 3 Status: 200 OK 4 Connection: close 5 X-Runtime: 1541 6 ETag: "e750924df3f2890ab7d8a560d0088c1a" 7 Content-Type: text/html; charset=3Dutf-8 8 Cache-Control: private, max-age=3D0, must-revalidate 9 Content-Length: 24376 10 Set-Cookie: flash=3D%7B%7D; path=3D/ 11 Set-Cookie: _bilderbuch_session=3D...; path=3D/; HttpOnly 0% [ ] 0 --.--K/s ETA --:-- does not work (waiting forever...) but - after killing unicorn_rails Macintosh-2:~> ls -la index.html.4 -rw-r--r-- 1 paulspon paulspon 24376 8. Jul 10:02 index.html.4 its there... unicorn_rails with more complex rails content: ( after adding your suggested socket.flush: ) ------------------------------------------------------------- no changes - still timeouts... a few more tests: ---------------------------- socket.write("HTTP/1.1 #{status}\r\n" \ "Date: #{Time.now.httpdate}\r\n" \ "Status: #{status}\r\n" \ "Connection: close\r\n" \ "#{OUT.join(Z)}\r\n") size =3D 0 puts "after socket.write HEADER" body.each { |chunk| size +=3D chunk.length socket.write(chunk) } puts "after socket.write BODY #{size}" socket.flush exit!(0) Content lengt matches output wget :... 9 Content-Length: 25257 ... after socket.write HEADER after socket.write BODY 25257 I, [2009-07-08T10:18:16.137773 #25334] INFO -- : reaped = # worker=3D0 I, [2009-07-08T10:18:16.161050 #25334] INFO -- : worker=3D0 spawning... ... hmmm - everything works as it should... i also tried this config.ru ---8<--- # config.ru require "config/environment" use Rack::Lint run ActionController::Dispatcher.new ---8<--- does this activate Rack::Lint ? this is all really strange - do i miss something simple in here ??? Best Paul !DSPAM:4a55a7665173716248820!