[PATCH] set RACK_ENV on startup

Wayne Larsen wayne at larsen.st
Tue Nov 3 22:51:12 EST 2009


On 2009-11-03, at 9:06 PM, Eric Wong wrote:

> Wayne Larsen <wayne at larsen.st> wrote:
>> Most stupid patch ever, but is there a reason not to set RACK_ENV on
>> startup with `unicorn`, as RAILS_ENV is set with `unicorn_rails`?
>
> Hi Wayne,
>
> Does anything use/depend on it?  `unicorn' is modeled after `rackup'  
> and
> I don't think it's a good idea to expose things if nothing uses it
> (rackup does not set it, either).
>
Passenger passes the RACK_ENV value to apps:
http://www.modrails.com/documentation/Users%20guide%20Nginx.html#RackEnv

As does thin:
http://github.com/macournoyer/thin/blob/master/lib/thin/controllers/controller.rb#L169

Sinatra uses it to set its environment:
http://github.com/sinatra/sinatra/blob/master/lib/sinatra/base.rb#L1013

As does Merb:
http://github.com/merb/merb/blob/master/merb-gen/lib/generators/templates/application/merb_stack/config.ru


> RAILS_ENV is an accepted standard for Rails applications and there are
> plenty of things that already depend on it.
>

It seems to me that RACK_ENV is a semi-standard. From a search of the  
rack group, this has come up before (unanswered):
http://groups.google.com/group/rack-devel/browse_frm/thread/109241d9246f91ab/4a0d2f61a7851a6c?lnk=gst&q=RACK_ENV#4a0d2f61a7851a6c

or  http://tinyurl.com/yl9re66

And this discussion:
http://groups.google.com/group/rack-devel/browse_frm/thread/822ce0551fbefa27/d52ea85fcb4e5a51?lnk=gst&q=RACK_ENV#d52ea85fcb4e5a51
also at http://tinyurl.com/yhssua2

where some suggested that it should be available in the rack  
environment instead of as a global ENV variable.

It seems like the pragmatic answer would be to set it.

Wayne



More information about the mongrel-unicorn mailing list