Question

I'm having troubles deploying a rack application with rack-http-logger middleware on Passenger Apache version. The problem is that Apache doesn't accept LOG method requests, which this middleware is interpreting, so I'm trying to use POST instead.

This is my config.ru:

require 'bundler'
Bundler.require

$stdout.sync = true

use Rack::HTTPLogger, :method => 'POST'
run lambda { [404, {'Content-Type' => 'text/html'}, ['Page Not Found']] }

Everything is working fine on Thin, but I'm having this error on Passenger:

App 57235 stderr: [ 2014-04-30 08:30:05.9440 57256/0x007ffe8c018af0(Worker 1) utils.rb:68 ]: 
*** Exception ArgumentError in Rack application object (wrong number of arguments (1 for 0)) (process 57256, thread 0x007ffe8c018af0(Worker 1)):
App 57235 stderr:   from config.ru:7:in `block (2 levels) in <main>'
App 57235 stderr:   from /Users/apps/.rvm/gems/ruby-1.9.3-p545/gems/rack-http-logger-0.1.0/lib/rack/http-logger.rb:17:in `call'
App 57235 stderr:   from /Users/apps/.rvm/gems/ruby-1.9.3-p545/gems/rack-http-logger-0.1.0/lib/rack/http-logger.rb:17:in `call'
App 57235 stderr:   from /Users/apps/.rvm/gems/ruby-1.9.3-p545/gems/passenger-4.0.41/lib/phusion_passenger/rack/thread_handler_extension.rb:74:in `process_request'
App 57235 stderr:   from /Users/apps/.rvm/gems/ruby-1.9.3-p545/gems/passenger-4.0.41/lib/phusion_passenger/request_handler/thread_handler.rb:141:in `accept_and_process_next_request'
App 57235 stderr:   from /Users/apps/.rvm/gems/ruby-1.9.3-p545/gems/passenger-4.0.41/lib/phusion_passenger/request_handler/thread_handler.rb:109:in `main_loop'
App 57235 stderr:   from /Users/apps/.rvm/gems/ruby-1.9.3-p545/gems/passenger-4.0.41/lib/phusion_passenger/request_handler.rb:448:in `block (3 levels) in start_threads'
[Wed Apr 30 08:30:05 2014] [error] [client 172.20.16.168] Premature end of script headers: 

Any ideas of what I could be doing wrong?

Was it helpful?

Solution

Your application object (the lambda that that you pass to run) does not conform to the Rack specification. According to the specification, it must accept exactly 1 argument, but your lambda accepts none and so you get an ArgumentError.

Phusion Passenger implements Rack differently than Thin does. Because the Rack specification does not specify how spec violations should be handled, each server handles it differently. This is why some (wrong) code which works on Thin, may not work on Phusion Passenger, and vice versa.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top