rack-devel archive mirror (unofficial) https://groups.google.com/group/rack-devel
 help / color / mirror / Atom feed
* Should server.run block?
@ 2012-11-04  5:14 Oscar Del Ben
  2012-11-04 11:09 ` Magnus Holm
  0 siblings, 1 reply; 3+ messages in thread
From: Oscar Del Ben @ 2012-11-04  5:14 UTC (permalink / raw)
  To: rack-devel

[-- Attachment #1: Type: text/plain, Size: 790 bytes --]

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


[-- Attachment #2: Type: text/html, Size: 4964 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Should server.run block?
  2012-11-04  5:14 Should server.run block? Oscar Del Ben
@ 2012-11-04 11:09 ` Magnus Holm
  2012-11-04 17:59   ` Oscar Del Ben
  0 siblings, 1 reply; 3+ messages in thread
From: Magnus Holm @ 2012-11-04 11:09 UTC (permalink / raw)
  To: rack-devel

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 <oscar@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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Should server.run block?
  2012-11-04 11:09 ` Magnus Holm
@ 2012-11-04 17:59   ` Oscar Del Ben
  0 siblings, 0 replies; 3+ messages in thread
From: Oscar Del Ben @ 2012-11-04 17:59 UTC (permalink / raw)
  To: rack-devel

[-- Attachment #1: Type: text/plain, Size: 1387 bytes --]

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<javascript:>> 
> 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 
>

[-- Attachment #2: Type: text/html, Size: 1890 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-11-04 17:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-04  5:14 Should server.run block? Oscar Del Ben
2012-11-04 11:09 ` Magnus Holm
2012-11-04 17:59   ` Oscar Del Ben

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).