about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-12-15 23:54:38 -0800
committerEric Wong <normalperson@yhbt.net>2009-12-16 00:07:17 -0800
commit64d95504ff2f00e5bf6ad1acff53bd7175bb2035 (patch)
treeb143fd14f11de68a25503faac522c7f75284781a
parentb7ade93403021c989bf9258b29a549b0e7f3692e (diff)
downloadzbatery-64d95504ff2f00e5bf6ad1acff53bd7175bb2035.tar.gz
avoid breaking user switching with a single process
$stdout may not have been a chown-able file descriptor,
so throw in a dummy object there that absorbs chown calls.
-rw-r--r--lib/zbatery.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/zbatery.rb b/lib/zbatery.rb
index 6b69e6d..dd904b1 100644
--- a/lib/zbatery.rb
+++ b/lib/zbatery.rb
@@ -34,6 +34,11 @@ module Zbatery
 
   class HttpServer < Rainbows::HttpServer
 
+    # this class is only used to avoid breaking Unicorn user switching
+    class DeadIO
+      def chown(*args); end
+    end
+
     # only used if no concurrency model is specified
     def worker_loop(worker)
       init_worker_process(worker)
@@ -86,7 +91,7 @@ module Zbatery
       rescue => e # hopefully ignores errors on Win32...
         logger.error "failed to setup signal handler: #{e.message}"
       end
-      worker = Worker.new(0, $stdout)
+      worker = Worker.new(0, DeadIO.new)
       before_fork.call(self, worker)
       worker_loop(worker) # runs forever
     end