WebFaction
Community site: login faq

I'm trying to use Rack::Builder's map in a config.ru file and I can't get it working under Passenger (Passenger 3.0.3, nginx 0.8.54, REE 1.8.7). I'm running the Passenger app from a subdirectory (example.com/hello), not sure if that's important.

This works:

run proc { |env|
  [200, {'Content-Type' => 'text/html'}, ['ahoy there']]
}

This does not:

map '/' do
  run proc { |env|
    [200, {'Content-Type' => 'text/html'}, ['ahoy there']]
  }
end

On my development machine, these rackup files both print ahoy there, as expected. On WebFaction, the first prints ahoy there, while the second returns 404. What am I missing?

Edit: for what it's worth, the second config.ru I show here works as expected on Heroku. I believe they use Thin where I'm trying to use Passenger on WebFaction, so not really an apples to apples comparison.

asked 17 May '11, 14:10

nwaite
112
accept rate: 0%

edited 18 May '11, 02:58


Does it work if you do bind it to the root of the domain, and not /hello? What does the rails/nginx logs say about the request?

permanent link

answered 17 May '11, 22:04

johns
5.4k412
accept rate: 23%

I don't have a domain handy whose root I can use for testing, but testing at the root of a subdomain I get the same results. The nginx error logs are empty, and the access logs just confirm the 404.

There's no rails involved anywhere, I'm literally testing the bare config.ru files I show above and nothing else. So there's no other logs that I'm aware of.

(18 May '11, 01:26) nwaite

I think the problem is that you don't have an app object in your config.ru. Does this work?

app = Rack::Builder.app do
    use Rack::Lint
    use Rack::ShowExceptions
    use Rack::ShowStatus
   lambda { |env| [200, {'Content-Type' => 'text/plain'}, ['ahoy there']] }
end
permanent link

answered 18 May '11, 02:22

David L ♦♦
1.4k13
accept rate: 45%

Doesn't work for me under Passenger on WebFaction, nor does it work on my development machine with rackup. Gives "undefined method `call' for nil:NilClass" locally; nginx just throws a 502 error.

config.ru files are eval'd in a Rack::Builder.new do #{config.ru contents} end.to_app block (as per the source). In fact, Rack::Builder.app is implemented just like that.

(18 May '11, 02:53) nwaite

Ah, right. It's been far too long since I did anything with Rack :/

Does it work if you just use rackup to start your app?

rackup -p $PORT config.ru

I set up a test app using rackup and a copy of your config.ru and it seems be working.

(18 May '11, 03:07) David L ♦♦
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×25
×5
×1

question asked: 17 May '11, 14:10

question was seen: 3,562 times

last updated: 18 May '11, 03:08

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2020 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM