English 中文(简体)
Sinatra on Rack under Passenger returning 0-byte pages
原标题:

I m trying to write a Sinatra app that will run on a shared Passenger server. For now, I d be happy just getting a "hello world", but something isn t working quite right. I have:

config.ru

require  vendor/sinatra-lib/sinatra.rb 
set :environment, :production
disable :run

require  myapp.rb 
run Sinatra::Application

myapp.rb

get  /  do
  "Hello world!"
end

and of course all the support libs I need for sinatra are under /vendor/sinatra-lib. I can rackup this exact load on my local machine, and it runs like a champ. However, on the remote machine, I get 0-byte responses for any URL I try to visit. Note that I have a /public directory, and I can view pages out of that successfully, so I guess Rack is still responding. Also, I can run a basic Rack app without any problems, so Rack must be configured correctly (at least, correctly for running Rack apps).

At this point, the only thing I can think of is to check the version of Rack, etc, on the remote server. I don t have full control over the box, so I don t really have log output to share. I can try to chase it down, if it s important, but I m hoping something will jump out at somebody.

最佳回答

Thank you all for playing, turned out to be a dependency issue -- the server I was deployed to was running a version of Rack that was too old to support Sinatra. Lots of good other stuff to think about, though.

问题回答

I think the problem is that the other sinatra files isn t in the load dir. Try to rename vendor/sinatra-lib into vendor/sinatra, and if it still doesn t work, try to add this in the top of your config.ru, in stead of require vendor/...

$: <<  vendor/sinatra 
require  sinatra 

A little side note: You are not required to pass the file extension (.rb) to require, so you could do require myapp instead of require myapp.rb .





相关问题
Ruby parser in Java

The project I m doing is written in Java and parsers source code files. (Java src up to now). Now I d like to enable parsing Ruby code as well. Therefore I am looking for a parser in Java that parses ...

rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

multiple ruby extension modules under one directory

Can sources for discrete ruby extension modules live in the same directory, controlled by the same extconf.rb script? Background: I ve a project with two extension modules, foo.so and bar.so which ...

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

热门标签