From fa0c8d7950f5f3f482e0691542e05c02b0db4a84 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 2 Mar 2009 17:49:19 -0800 Subject: Make USR1 rotate log files by default 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. --- lib/unicorn.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib') 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 -- cgit v1.2.3-24-ge0c7