[PATCH] make stderr_path/stdout_path support IO objects directly

Benedikt Böhm bb at xnull.de
Thu Mar 22 07:14:09 UTC 2012


---
 lib/unicorn/configurator.rb |    2 +-
 lib/unicorn/http_server.rb  |    6 +++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/unicorn/configurator.rb b/lib/unicorn/configurator.rb
index 89cbf5c..c9b6816 100644
--- a/lib/unicorn/configurator.rb
+++ b/lib/unicorn/configurator.rb
@@ -559,7 +559,7 @@ private
 
   def set_path(var, path) #:nodoc:
     case path
-    when NilClass, String
+    when NilClass, String, IO
       set[var] = path
     else
       raise ArgumentError
diff --git a/lib/unicorn/http_server.rb b/lib/unicorn/http_server.rb
index 0c2af5d..bd71fbf 100644
--- a/lib/unicorn/http_server.rb
+++ b/lib/unicorn/http_server.rb
@@ -698,7 +698,11 @@ class Unicorn::HttpServer
   end
 
   def redirect_io(io, path)
-    File.open(path, 'ab') { |fp| io.reopen(fp) } if path
+    if path.is_a?(IO)
+      io.reopen(path)
+    elsif path
+      io.reopen(path, 'ab')
+    end
     io.sync = true
   end
 
-- 
1.7.4.5



More information about the mongrel-unicorn mailing list