summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-04-23 23:27:02 -0700
committerEric Wong <normalperson@yhbt.net>2009-04-24 08:36:18 +0000
commit3baf3e68c1a7f4d1187e292cc5001fb1dc379194 (patch)
treeb95427636aa5516304940e7be512823baa89d6a5
parent474a587c2b537157b443dca4cba1b81e97f46143 (diff)
Seems like a good idea to be able to relocate log
files on a config reload.
-rw-r--r--lib/unicorn.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/unicorn.rb b/lib/unicorn.rb
index 6d0eccb..9510e4b 100644
--- a/lib/unicorn.rb
+++ b/lib/unicorn.rb
@@ -101,9 +101,6 @@ module Unicorn
       raise ArgumentError, "no listeners" if LISTENERS.empty?
       self.pid = @config[:pid]
       build_app! if @preload_app
-      File.open(@stderr_path, "a") { |fp| $stderr.reopen(fp) } if @stderr_path
-      File.open(@stdout_path, "a") { |fp| $stdout.reopen(fp) } if @stdout_path
-      $stderr.sync = $stdout.sync = true
       spawn_missing_workers
       self
     end
@@ -139,6 +136,9 @@ module Unicorn
       (set_names - cur_names).each { |addr| listen(addr) }
     end
 
+    def stdout_path=(path); redirect_io($stdout, path); end
+    def stderr_path=(path); redirect_io($stderr, path); end
+
     # sets the path for the PID file of the master process
     def pid=(path)
       if path
@@ -598,5 +598,10 @@ module Unicorn
               START_CTX[:argv]).join(' ')
     end
 
+    def redirect_io(io, path)
+      File.open(path, 'a') { |fp| io.reopen(fp) } if path
+      io.sync = true
+    end
+
   end
 end