about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-03-02 17:49:19 -0800
committerEric Wong <normalperson@yhbt.net>2009-03-03 11:13:19 -0800
commitfa0c8d7950f5f3f482e0691542e05c02b0db4a84 (patch)
treeadeba2a959ed360ef82b0f32fd7e4e044667aad9 /lib
parentdf9f6823188b4189a46b21494d215a07dc6add36 (diff)
downloadunicorn-fa0c8d7950f5f3f482e0691542e05c02b0db4a84.tar.gz
I consider it a sensible default for long-running servers.
Additionally, there is no easy way to make USR1 rotate the
master process log without this.
Diffstat (limited to 'lib')
-rw-r--r--lib/unicorn.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/unicorn.rb b/lib/unicorn.rb
index 6ab42c9..31af720 100644
--- a/lib/unicorn.rb
+++ b/lib/unicorn.rb
@@ -182,6 +182,7 @@ module Unicorn
             break
           when 'USR1' # user-defined (probably something like log reopening)
             kill_each_worker('USR1')
+            Unicorn::Util.reopen_logs
             reset_master
           when 'USR2' # exec binary, stay alive in case something went wrong
             reexec
@@ -392,6 +393,12 @@ module Unicorn
     def init_worker_process(worker)
       TRAP_SIGS.each { |sig| trap(sig, 'IGNORE') }
       trap('CHLD', 'DEFAULT')
+      trap('USR1') do
+        @logger.info "worker=#{worker.nr} rotating logs..."
+        Unicorn::Util.reopen_logs
+        @logger.info "worker=#{worker.nr} done rotating logs"
+      end
+
       $0 = "unicorn worker[#{worker.nr}]"
       @rd_sig.close if @rd_sig
       @wr_sig.close if @wr_sig