From mboxrd@z Thu Jan 1 00:00:00 1970 Delivered-To: chneukirchen@gmail.com Received: by 10.49.96.6 with SMTP id do6csp138113qeb; Sun, 4 Nov 2012 09:59:09 -0800 (PST) Return-Path: Received-SPF: pass (google.com: domain of rack-devel+bncBCPPBDHB7QGRB3GZ3KCAKGQEL5U2LOI@googlegroups.com designates 10.68.253.129 as permitted sender) client-ip=10.68.253.129 Authentication-Results: mr.google.com; spf=pass (google.com: domain of rack-devel+bncBCPPBDHB7QGRB3GZ3KCAKGQEL5U2LOI@googlegroups.com designates 10.68.253.129 as permitted sender) smtp.mail=rack-devel+bncBCPPBDHB7QGRB3GZ3KCAKGQEL5U2LOI@googlegroups.com; dkim=pass header.i=rack-devel+bncBCPPBDHB7QGRB3GZ3KCAKGQEL5U2LOI@googlegroups.com Received: from mr.google.com ([10.68.253.129]) by 10.68.253.129 with SMTP id aa1mr5501043pbd.17.1352051949284 (num_hops = 1); Sun, 04 Nov 2012 09:59:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; h=x-beenthere:date:from:to:message-id:in-reply-to:references:subject :mime-version:x-original-sender:reply-to:precedence:mailing-list :list-id:x-google-group-id:list-post:list-help:list-archive:sender :list-subscribe:list-unsubscribe:content-type; bh=BjdUErOodobZEcccSANSPTmgcwwIgi3DBpy0E0RS4UM=; b=S5K/Z76z+6SzwBWz5Fd4rAi3ua3h+bH0NPbrMD5YzBosUDmGMeBO6RPZeL2NYcopEj YhG4xomlvi/SmZC7zGd4qozhhsjEPP1THuAOD5Hv/NV/Qdcir/ziNTfnJ387SKPEU6oN lPV7P0JdGXfShjxYQHjIM8lCzZqry8cRaV6INYmqE/1ATyFuBhxfGr9yqz3Qgling9HB TZAY3F+31+MogaJX34oJ/yLno6pCqpX6n1ZgQetip8VIxmag0Y1zIZYpneKiTRSrPvya uetf/xSBLq7e/9eiFdk81PbLl8yQe3XXYgVU2t2JqCw89KNhsWH6gCrkTUabCxg/u+10 EY2Q== Received: by 10.68.253.129 with SMTP id aa1mr1637271pbd.17.1352051948958; Sun, 04 Nov 2012 09:59:08 -0800 (PST) X-BeenThere: rack-devel@googlegroups.com Received: by 10.68.75.70 with SMTP id a6ls21170793pbw.5.gmail; Sun, 04 Nov 2012 09:59:08 -0800 (PST) Received: by 10.68.230.33 with SMTP id sv1mr1642729pbc.18.1352051948003; Sun, 04 Nov 2012 09:59:08 -0800 (PST) Date: Sun, 4 Nov 2012 09:59:07 -0800 (PST) From: Oscar Del Ben To: rack-devel@googlegroups.com Message-Id: In-Reply-To: References: <51e063f8-e986-464b-9d5b-def5f1d908aa@googlegroups.com> Subject: Re: Should server.run block? MIME-Version: 1.0 X-Original-Sender: oscar@oscardelben.com Reply-To: rack-devel@googlegroups.com Precedence: list Mailing-list: list rack-devel@googlegroups.com; contact rack-devel+owners@googlegroups.com List-ID: X-Google-Group-Id: 486215384060 List-Post: , List-Help: , List-Archive: Sender: rack-devel@googlegroups.com List-Subscribe: , List-Unsubscribe: , Content-Type: multipart/alternative; boundary="----=_Part_209_17331132.1352051947123" ------=_Part_209_17331132.1352051947123 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Thanks. That helped On Sunday, November 4, 2012 3:10:16 AM UTC-8, Magnus Holm wrote: > > config.ru only specifies an app + middleware chain, not the server > part. Rack::Builder doesn't run anything; it just builds up an > app-object for you. > > In this case you should write a separate binary: > > app = Rack::Builder.parse_file("config.ru") > Rack::Handler::Hare.run app > > On Sun, Nov 4, 2012 at 6:14 AM, Oscar Del Ben > > wrote: > > > > Hello, > > > > I'm trying to build a rack handler and I've noticed that if I don't > block from server.run then Rack::Builder fails. In my config.ru file I do > the following: > > > > Rack::Handler::Hare.run MyApp.new > > > > but then Rack::Builder fails to parse the file when calling the to_app > method: > > > > def to_app > > app = @map ? generate_map(@run, @map) : @run > > fail "missing run or map statement" unless app > > @use.reverse.inject(app) { |a,e| e[a] } > > end > > > > The problem here is that I never call run explicitly from config.ru, > since I want to use my custom handler, which doesn't block. > > > > I've looked into the thin source code and server.run actually blocks, so > that Rack::Builder#to_app is never called. Is this how the server is > supposed to behave or am I missing something? > > > > Many thanks, > > > > Oscar Del Ben > ------=_Part_209_17331132.1352051947123 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit Thanks. That helped

On Sunday, November 4, 2012 3:10:16 AM UTC-8, Magnus Holm wrote:
config.ru only specifies an app + middleware chain, not the server
part. Rack::Builder doesn't run anything; it just builds up an
app-object for you.

In this case you should write a separate binary:

  app = Rack::Builder.parse_file("config.ru")
  Rack::Handler::Hare.run app

On Sun, Nov 4, 2012 at 6:14 AM, Oscar Del Ben <os...@oscardelben.com> wrote:
>
> Hello,
>
> I'm trying to build a rack handler and I've noticed that if I don't block from server.run then Rack::Builder fails. In my config.ru file I do the following:
>
> Rack::Handler::Hare.run MyApp.new
>
> but then Rack::Builder fails to parse the file when calling the to_app method:
>
> def to_app
>   app = @map ? generate_map(@run, @map) : @run
>   fail "missing run or map statement" unless app
>   @use.reverse.inject(app) { |a,e| e[a] }
> end
>
> The problem here is that I never call run explicitly from config.ru, since I want to use my custom handler, which doesn't block.
>
> I've looked into the thin source code and server.run actually blocks, so that Rack::Builder#to_app is never called. Is this how the server is supposed to behave or am I missing something?
>
> Many thanks,
>
> Oscar Del Ben
------=_Part_209_17331132.1352051947123--