Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Weird problem with Rails app and Mongrel

I originally posted a question relating to this problem on serverfault.com: https://serverfault.com/questions/152587/apache-mod-proxy-to-another-server

I have since realized that this is not an issue with my server setup, but my rails application. I have set this application up server-wise the exact same as another functioning rails app I have running on the same server. When I start the server my mongrel.log looks like this:

** Daemonized, any open files are closed.  Look at /var/www/osuwebdev/tmp/pids/mongrel.pid and log/mongrel.log for info.
** Starting Mongrel listening at 0.0.0.0:8080
** Starting Rails with production environment...
** Rails loaded.
** Loading any Rails specific GemPlugins
** Signals ready.  TERM => stop.  USR2 => restart.  INT => stop (no restart).
** Rails signals registered.  HUP => reload (without restart).  It might not work well.
** Mongrel 1.1.5 available at 0.0.0.0:8080
** Writing PID file to /var/www/osuwebdev/tmp/pids/mongrel.pid

When I load a page this pops up in the log:

Wed Jun 30 19:46:10 +0000 2010: Error calling Dispatcher.dispatch #<NoMethodError: undefined method `[]' for nil:NilClass>
/var/lib/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/cgi.rb:108:in `send_cookies'
/var/lib/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/cgi.rb:136:in `out'
/var/lib/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/http_response.rb:65:in `start'
/var/lib/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/cgi.rb:135:in `out'
/var/lib/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:81:in `process'
/var/lib/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:159:in `process_client'
/var/lib/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:158:in `each'
/var/lib/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:158:in `process_client'
/var/lib/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `run'
/var/lib/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `initialize'
/var/lib/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `new'
/var/lib/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `run'
/var/lib/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:268:in `initialize'
/var/lib/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:268:in `new'
/var/lib/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:268:in `run'
/var/lib/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:282:in `run'
/var/lib/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:281:in `each'
/var/lib/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:281:in `run'
/var/lib/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:128:in `run'
/var/lib/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/command.rb:212:in `run'
/var/lib/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281
/usr/local/bin/mongrel_rails:19:in `load'
/usr/local/bin/mongrel_rails:19

I cannot figure out what is different about this app that may cause this issue.

like image 827
trobrock Avatar asked Jun 30 '10 19:06

trobrock


1 Answers

I believe this is a weird combination of bugs in Rack, Mongrel, and Rails.

  1. Save this ruby code in your app to config/mongrel.rb: http://gist.github.com/471663

  2. In your config/environment.rb, at the very end of the file add: require File.join(File.dirname(File.expand_path(FILE)), 'mongrel')

  3. In that same file add this line in the Rails::initializer.run block: config.gem "mongrel"

Longer explanation of the problem here: https://rails.lighthouseapp.com/projects/8994/tickets/4690-mongrel-doesnt-work-with-rails-238

This has definitely worked for a Rails 2.3.8 app, though I patched it slightly differently than described above.

like image 197
rkb Avatar answered Oct 10 '22 09:10

rkb