unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: Eric Wong <normalperson@yhbt.net>
To: unicorn list <mongrel-unicorn@rubyforge.org>
Subject: Re: [PATCH] set RACK_ENV on startup
Date: Wed, 4 Nov 2009 17:13:55 +0000	[thread overview]
Message-ID: <20091104171355.GC28983@dcvr.yhbt.net> (raw)
In-Reply-To: <20091104052908.GA10096@dcvr.yhbt.net>

Eric Wong <normalperson@yhbt.net> wrote:
> I've pushed out the following change:

Actually, I think I'll go with this:

>From ae2afbcc7dbac0af3256aa8b46afebf6e309bac0 Mon Sep 17 00:00:00 2001
From: Eric Wong <normalperson@yhbt.net>
Date: Wed, 4 Nov 2009 17:09:26 +0000
Subject: [PATCH] bin/unicorn: allow RACK_ENV to be passed from parent

This makes our RACK_ENV handling like our RAILS_ENV
handling for unicorn_rails, removing the redundant
local variable.
---
 bin/unicorn |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/bin/unicorn b/bin/unicorn
index 1916098..225e819 100755
--- a/bin/unicorn
+++ b/bin/unicorn
@@ -3,7 +3,7 @@
 require 'unicorn/launcher'
 require 'optparse'
 
-env = "development"
+ENV["RACK_ENV"] ||= "development"
 daemonize = false
 listeners = []
 options = { :listeners => listeners }
@@ -58,7 +58,7 @@ opts = OptionParser.new("", 24, '  ') do |opts|
 
   opts.on("-E", "--env ENVIRONMENT",
           "use ENVIRONMENT for defaults (default: development)") do |e|
-    env = e
+    ENV["RACK_ENV"] = e
   end
 
   opts.on("-D", "--daemonize", "run daemonized in the background") do |d|
@@ -118,8 +118,6 @@ if config =~ /\.ru$/
   end
 end
 
-ENV['RACK_ENV'] = env
-
 require 'pp' if $DEBUG
 
 app = lambda do ||
@@ -135,7 +133,7 @@ app = lambda do ||
     Object.const_get(File.basename(config, '.rb').capitalize)
   end
   pp({ :inner_app => inner_app }) if $DEBUG
-  case env
+  case ENV["RACK_ENV"]
   when "development"
     Rack::Builder.new do
       use Rack::CommonLogger, $stderr
-- 
-- 
Eric Wong

      reply	other threads:[~2009-11-04 17:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-04  1:24 [PATCH] set RACK_ENV on startup Wayne Larsen
2009-11-04  3:06 ` Eric Wong
2009-11-04  3:51   ` Wayne Larsen
2009-11-04  5:29     ` Eric Wong
2009-11-04 17:13       ` Eric Wong [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://yhbt.net/unicorn/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091104171355.GC28983@dcvr.yhbt.net \
    --to=normalperson@yhbt.net \
    --cc=mongrel-unicorn@rubyforge.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhbt.net/unicorn.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).