From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS33070 50.56.128.0/17 X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID shortcircuit=no autolearn=unavailable version=3.3.2 X-Original-To: archivist@yhbt.net Delivered-To: archivist@dcvr.yhbt.net Received: from rubyforge.org (50-56-192-79.static.cloud-ips.com [50.56.192.79]) by dcvr.yhbt.net (Postfix) with ESMTP id 28D811F728 for ; Tue, 29 Jan 2013 03:27:32 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by rubyforge.org (Postfix) with ESMTP id BDCC12E099; Tue, 29 Jan 2013 03:27:31 +0000 (UTC) X-Original-To: mongrel-unicorn@rubyforge.org Delivered-To: mongrel-unicorn@rubyforge.org X-Greylist: delayed 328 seconds by postgrey-1.31 at rubyforge; Tue, 29 Jan 2013 03:27:22 UTC Received: from mail-pa0-f47.google.com (mail-pa0-f47.google.com [209.85.220.47]) by rubyforge.org (Postfix) with ESMTP id B7E3C2E084 for ; Tue, 29 Jan 2013 03:27:22 +0000 (UTC) Received: by mail-pa0-f47.google.com with SMTP id fa10so102235pad.6 for ; Mon, 28 Jan 2013 19:27:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=godfat.org; s=google; h=x-received:from:to:cc:subject:date:message-id:x-mailer; bh=JcRjy56jVv0BwFr+v/spG0ta6ljXn3Lb83ox5c47+AU=; b=nh8rMCQXd4SW1Yp0iul5mnWbB1BFiOdF3f4jNTDBHsRgSH10EYmN0Phxa2dpxSDSAM Ci/BVk45Kb+kShutUL+dqd+/8W35Vw9w3NXnUbktVWdN0fGsNpuWeaeQz9AOnr1ku1Gn yV3ByKR4kaAu2w0jhZnnwtPMlpu8wPruQS0xk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=JcRjy56jVv0BwFr+v/spG0ta6ljXn3Lb83ox5c47+AU=; b=jLJG9CtDsJd/oSt+puRGXzkqq/lnb+r7kzSFseHl22xwofBhRS24RlYLdwi1SnZmvU iUJhYDAhX9QA6Qt/Mj9NA2BdqsK0V1TNhH6XVPXGstyrRpqnzBMFQ0l6oYChmjLRr0Zd 2UHOAaH7vySekTocrvRKKWptsC3PARlw+zZVZgqajGBNBBIIUqO38Vdx5ofjRF7abiY6 ioxE7Kn6CkYvJlACgvdmhTiW47TRF2XIncOrVdSthMt/g6xYQtJVSLnX8mrrW2FDHNJJ bFAIntdyAe9Ij4pdTN7pjotswTLdI9HS7yKEIZ/MhWzHdTXNwKkKlH0Eup2ap70e5ADE weZw== X-Received: by 10.68.243.105 with SMTP id wx9mr79412pbc.74.1359429714173; Mon, 28 Jan 2013 19:21:54 -0800 (PST) Received: from 220-135-160-129.hinet-ip.hinet.net (220-135-160-129.HINET-IP.hinet.net. [220.135.160.129]) by mx.google.com with ESMTPS id ix9sm7483328pbc.7.2013.01.28.19.21.51 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 28 Jan 2013 19:21:53 -0800 (PST) From: Lin Jen-Shin To: mongrel-unicorn@rubyforge.org Subject: [PATCH] Add -N or --no-default-middleware option. Date: Tue, 29 Jan 2013 11:21:19 +0800 Message-Id: <1359429679-21255-1-git-send-email-godfat@godfat.org> X-Mailer: git-send-email 1.8.1.1 X-Gm-Message-State: ALoCoQm8ApdxyIpYr9Yjv3DMTmE/ivgtmLk8pB221bDdFqgfX2QeoIpdTIgmgyhz+RpaNyLAyCv4 Cc: Lin Jen-Shin 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: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: mongrel-unicorn-bounces@rubyforge.org Errors-To: mongrel-unicorn-bounces@rubyforge.org This would prevent Unicorn from adding default middleware, as if RACK_ENV were always none. (not development nor deployment) This should also be applied to `rainbows' and `zbatery' as well. One of the reasons to add this is to avoid conflicting RAILS_ENV and RACK_ENV. It would be helpful in the case where a Rails application and Rack application are composed together, while we want Rails app runs under development and Rack app runs under none (if we don't want those default middleware), and we don't really want to make RAILS_ENV set to development and RACK_ENV to none because it might be confusing. Note that Rails would also look into RACK_ENV. Another reason for this is that only `rackup' would be inserting those default middleware. Both `thin' and `puma' would not do this, nor does Rack::Handler.get.run which is used in Sinatra. So using this option would make it work differently from `rackup' but somehow more similar to `thin' or `puma'. Discussion thread on the mailing list: http://rubyforge.org/pipermail/mongrel-unicorn/2013-January/001675.html --- bin/unicorn | 5 +++++ lib/unicorn.rb | 2 ++ 2 files changed, 7 insertions(+) diff --git a/bin/unicorn b/bin/unicorn index 9962b58..415d164 100755 --- a/bin/unicorn +++ b/bin/unicorn @@ -58,6 +58,11 @@ op = OptionParser.new("", 24, ' ') do |opts| ENV["RACK_ENV"] = e end + opts.on("-N", "--no-default-middleware", + "no default middleware even if RACK_ENV is development") do |e| + rackup_opts[:no_default_middleware] = true + end + opts.on("-D", "--daemonize", "run daemonized in the background") do |d| rackup_opts[:daemonize] = !!d end diff --git a/lib/unicorn.rb b/lib/unicorn.rb index d96ff91..f0ceffe 100644 --- a/lib/unicorn.rb +++ b/lib/unicorn.rb @@ -49,6 +49,8 @@ module Unicorn pp({ :inner_app => inner_app }) if $DEBUG + return inner_app if op[:no_default_middleware] + # return value, matches rackup defaults based on env # Unicorn does not support persistent connections, but Rainbows! # and Zbatery both do. Users accustomed to the Rack::Server default -- 1.8.1.1 _______________________________________________ Unicorn mailing list - mongrel-unicorn@rubyforge.org http://rubyforge.org/mailman/listinfo/mongrel-unicorn Do not quote signatures (like this one) or top post when replying