2
votes

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.

2
Follow up: I think the server turns out to be running an old version of Rack (Rack::VERSION reports 0.10! Is that even possible?) so I'm going to see if I can get it upgraded. - Coderer
(As an aside, it would be nice if Sinatra could check its dependencies and die gracefully if they're not met) - Coderer

2 Answers

0
votes

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

0
votes

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.