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
Lin Jen-Shin <godfat at godfat.org> wrote:> + opts.on("-N", "--no-default-middleware", > + "no default middleware even if RACK_ENV is development") do |e|RACK_ENV=deployment also loads middleware, so I think it''s more accurate with: do not load middleware implied by RACK_ENV This also puts us back within the 80-column limit imposed by "test_help" in test/exec/test_exec.rb Will sign-off and push that change squashed unless there are objections. I also just bumped master to rack 1.5.1, which fixes the Rack::Lint test regression in 1.5.0. Will pull in the "hijack" branch into master soon (and release 4.6.0) since all my questions about it have been answered in rack-devel.
Eric Wong <normalperson at yhbt.net> wrote:> Lin Jen-Shin <godfat at godfat.org> wrote: > > + opts.on("-N", "--no-default-middleware", > > + "no default middleware even if RACK_ENV is development") do |e| > > RACK_ENV=deployment also loads middleware, so I think it''s more accurate > with: > > do not load middleware implied by RACK_ENV > > This also puts us back within the 80-column limit imposed by "test_help" > in test/exec/test_exec.rbHeh, turns out there''s a bug in test_exec.rb (but I still don''t think mentioning "development" for this help is correct)>From ee3ada3c697311ab0a799fcdc492ae062e7d5128 Mon Sep 17 00:00:00 2001From: Eric Wong <normalperson at yhbt.net> Date: Tue, 29 Jan 2013 03:56:16 +0000 Subject: [PATCH] test_exec: do not count ''\n'' as column width This off-by-one error was incorrectly rejecting a line which would''ve been readable without wrapping on an 80-column terminal. --- test/exec/test_exec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/test/exec/test_exec.rb b/test/exec/test_exec.rb index 1cee2b7..10a1bae 100644 --- a/test/exec/test_exec.rb +++ b/test/exec/test_exec.rb @@ -323,6 +323,7 @@ EOF # mobile phone or netbook on a slow connection :) assert lines.size <= 24, "help height fits in an ANSI terminal window" lines.each do |line| + line.chomp! assert line.size <= 80, "help width fits in an ANSI terminal window" end end -- 1.8.1.1.253.g2934a48
Lin Jen-Shin (godfat)
2013-Jan-29 04:03 UTC
[PATCH] Add -N or --no-default-middleware option.
On Tue, Jan 29, 2013 at 11:52 AM, Eric Wong <normalperson at yhbt.net> wrote:> Lin Jen-Shin <godfat at godfat.org> wrote: >> + opts.on("-N", "--no-default-middleware", >> + "no default middleware even if RACK_ENV is development") do |e| > > RACK_ENV=deployment also loads middleware, so I think it''s more accurate > with: > > do not load middleware implied by RACK_ENV > > This also puts us back within the 80-column limit imposed by "test_help" > in test/exec/test_exec.rbOh right, I only remembered to keep the source within 80-column limit, but forgot that the output might be longer than source. Thanks for the better wordings. I updated the patch for Zbatery, but it''s too late for Rainbows though.> Will sign-off and push that change squashed unless there are objections.Surely, thanks!> I also just bumped master to rack 1.5.1, which fixes the Rack::Lint > test regression in 1.5.0. > > Will pull in the "hijack" branch into master soon (and release 4.6.0) > since all my questions about it have been answered in rack-devel.I haven''t had a chance to read hijack more, looking forward to it :)