From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS14383 205.234.109.0/24 X-Spam-Status: No, score=-0.5 required=5.0 tests=AWL,MSGID_FROM_MTA_HEADER, RP_MATCHES_RCVD shortcircuit=no autolearn=unavailable version=3.3.2 Path: news.gmane.org!not-for-mail From: Eric Wong Newsgroups: gmane.comp.lang.ruby.unicorn.general Subject: Re: [PATCH] set RACK_ENV on startup Date: Tue, 3 Nov 2009 21:29:08 -0800 Message-ID: <20091104052908.GA10096@dcvr.yhbt.net> References: <20091104030635.GA5282@dcvr.yhbt.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1257312561 24798 80.91.229.12 (4 Nov 2009 05:29:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 4 Nov 2009 05:29:21 +0000 (UTC) To: unicorn list Original-X-From: mongrel-unicorn-bounces@rubyforge.org Wed Nov 04 06:29:13 2009 Return-path: Envelope-to: gclrug-mongrel-unicorn@m.gmane.org X-Original-To: mongrel-unicorn@rubyforge.org Delivered-To: mongrel-unicorn@rubyforge.org Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) X-BeenThere: mongrel-unicorn@rubyforge.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: mongrel-unicorn-bounces@rubyforge.org Errors-To: mongrel-unicorn-bounces@rubyforge.org Xref: news.gmane.org gmane.comp.lang.ruby.unicorn.general:128 Archived-At: Received: from rubyforge.org ([205.234.109.19]) by lo.gmane.org with esmtp (Exim 4.50) id 1N5YQi-0005j9-O0 for gclrug-mongrel-unicorn@m.gmane.org; Wed, 04 Nov 2009 06:29:12 +0100 Received: from rubyforge.org (rubyforge.org [127.0.0.1]) by rubyforge.org (Postfix) with ESMTP id DF9CC159807A; Wed, 4 Nov 2009 00:29:11 -0500 (EST) Received: from dcvr.yhbt.net (dcvr.yhbt.net [64.71.152.64]) by rubyforge.org (Postfix) with ESMTP id C683C18581EF for ; Wed, 4 Nov 2009 00:29:09 -0500 (EST) Received: from localhost (unknown [127.0.2.5]) by dcvr.yhbt.net (Postfix) with ESMTP id F0C2F1F676; Wed, 4 Nov 2009 05:29:08 +0000 (UTC) Wayne Larsen wrote: > On 2009-11-03, at 9:06 PM, Eric Wong wrote: >> Wayne Larsen wrote: >> >> 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 > It seems like the pragmatic answer would be to set it. Agreed. Thanks for the research and links! I've pushed out the following change: >>From c7f2242a53ceec6892bd72f0df771266d5193004 Mon Sep 17 00:00:00 2001 From: Wayne Larsen Date: Tue, 3 Nov 2009 21:12:47 -0800 Subject: [PATCH] bin/unicorn: set ENV["RACK_ENV"] on startup Although not currently part of the Rack specification, ENV["RACK_ENV"] is at least a de facto standard. Some of the popular Rack servers (Thin, Passenger) and frameworks (Merb, Sinatra) already set or use it. ML-Ref: Acked-by: Eric Wong [ew: setenv always, not just on CLI + commit message] --- bin/unicorn | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/bin/unicorn b/bin/unicorn index 0fed11e..1916098 100755 --- a/bin/unicorn +++ b/bin/unicorn @@ -118,6 +118,8 @@ if config =~ /\.ru$/ end end +ENV['RACK_ENV'] = env + require 'pp' if $DEBUG app = lambda do || -- Eric Wong