Should server.run block?

25 views
Skip to first unread message

Oscar Del Ben

unread,
Nov 4, 2012, 1:14:09 AM11/4/12
to rack-...@googlegroups.com
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

Magnus Holm

unread,
Nov 4, 2012, 6:09:54 AM11/4/12
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

Oscar Del Ben

unread,
Nov 4, 2012, 12:59:07 PM11/4/12
to rack-...@googlegroups.com
Thanks. That helped
Reply all
Reply to author
Forward
0 new messages