jump to navigation

Track which mongrel handled a request December 26, 2007

Posted by John Dewey in Code, Configuration, Example, Mongrel, Rails, WebServers.
add a comment

I wrote a plugin which collects system information, and returns the data as HTML comments at the bottom of the page. When running multi-system / multi-Mongrel environments, knowing which server and Mongrel handled a request is paramount.

Unfortunately, getting a handle on this information is difficult, since ‘request.port’, ‘request.env[‘HTTP_HOST’], and ‘request.env[‘SERVER_PORT’], display the origin port, when your Mongrels are behind a reverse proxy.

Ezra clued me into a nice hack.You can add the following code to environment.rb, or in our case the plugin’s init.rb.

Apache mod_rewrite maintenance.html woes December 15, 2007

Posted by John Dewey in Apache, Configuration, Rails, WebServers.
add a comment

Every self.respecting Rails site, has a configuring Rails with Apache section.

The recipe contains a mod_rewrite rule, allowing staff to dynamically enable or disable maintenance mode. The mod_rewrite rule, however, does not work on Solaris, OS X or systems with a ‘/system’ directory.

I have notified the Pragmatic Studio folks, and Charles (who wrote the documentation hosted at http://mongrel.rubyforge.org/).  Below are further details of the problem, along with a solution.  Hopefully the word gets out.

Rails environment file “inheritance” December 15, 2007

Posted by John Dewey in Code, Configuration, Example, Rails.
2 comments

Wouldn’t it be nice if  Rails could inherit behavior from a given environment file? Here is a DRY approach when adding new environments:

Add the following to your new environment file:

eval File.read("#{RAILS_ROOT}/..../production.rb")