views:

508

answers:

3

Hello Stackies,

I'm deploying a Sinatra app using passenger. The deployed app is working, but not entirely: some paths work fine, others simply render a blank page. I can't seem to find any major differences between the routes that work and the routes that don't, and I can't seem to track down any errors..

Handlers

I have defined the not_found and error handlers as follows:

not_found do
  '404. Bummer!'
end

error do
  'Nasty error: ' + env['sinatra.error'].name
end

These work fine on my local machine, both in development and production, but I never see these come up on the server.

Apache Logs

When I tail Apache's access.log and hit one of the broken paths, I see a 500:

helpers [27/Oct/2009:15:54:59 -0400] "GET /admin/member_photos/photos HTTP/1.1" 500 20 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3"

rack_hoptoad

I've also installed and configured rack_hoptoad middleware in my config.ru, but no exceptions are making it to hoptoad.

# Send exceptions to hoptoad
require 'rack_hoptoad'
use Rack::HoptoadNotifier, 'MY_API_KEY'

logging

I've set up logging like so..

set :raise_errors => true
set :logging, true

log = File.new("log/sinatra.log", "a+")
STDOUT.reopen(log)
STDERR.reopen(log)

require 'logger'
configure do
  LOGGER = Logger.new("log/sinatra.log") 
end

helpers do
  def logger
    LOGGER
  end
end

This setup lets me call logger.info within my routes, which works locally and on the server for the working routes, but the broken paths don't get far enough to call logger.info.

What to do?

Any ideas as to how I can see what's causing the 500 errors? Thanks for any help!

A: 

Maybe there's something wrong with your log setup?

Redirect STDERR when running the Sinatra server so you can read it. Like:

ruby myapp.rb -p 1234 > log/app.log 2>&1
Pedro
+3  A: 

I would try using the Rack::ShowExceptions middleware to try and trace out the problem. In your config.ru add these two lines before the run call:

require 'rubygems'
require 'your-app'

use Rack::ShowExceptions

run YourApp

That should catch and display the backtrace for any exceptions occurring in Rack or in your app. That should give you more details to work with, at least that would be the hope.

James Thompson
A: 

Thanks for the responses, but I didn't end up needing to use them. I was originally deploying the app in a sub-URI configuration. When I deployed the app to it's own subdomain instead, the problems went away.

So.. I'm not really sure what the problem was, but getting rid of this line is my Apache configuration for the site is what resolved things:

Redirect permanent / https://www.example.org/admin/member_photos/
Zeke