about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-11-13 11:10:24 +0000
committerEric Wong <normalperson@yhbt.net>2009-11-13 21:34:43 +0000
commit0a0754fc3918b65d0888e3832071086b02e05e97 (patch)
treeee1dfcbccd0827b26b4d64fb3da3cdd9f190b95c
parent4d5a366f386e0f8a0b667e3071a6c027ae560fdd (diff)
downloadrainbows-0a0754fc3918b65d0888e3832071086b02e05e97.tar.gz
Permissions for the logs could've been badly set by the master.
So we we'll let the master reopen them and refork children to
get around this problem.  We have to be more careful when
reopening logs because we can reopen them in the middle of
client requests (we have to) whereas Unicorn has the luxury
of _knowing_ it has no active clients when it does the reopen.
-rw-r--r--lib/rainbows/base.rb2
-rw-r--r--lib/rainbows/http_server.rb8
2 files changed, 9 insertions, 1 deletions
diff --git a/lib/rainbows/base.rb b/lib/rainbows/base.rb
index 03cf624..4597239 100644
--- a/lib/rainbows/base.rb
+++ b/lib/rainbows/base.rb
@@ -23,7 +23,7 @@ module Rainbows
       # we're don't use the self-pipe mechanism in the Rainbows! worker
       # since we don't defer reopening logs
       HttpServer::SELF_PIPE.each { |x| x.close }.clear
-      trap(:USR1) { reopen_worker_logs(worker.nr) rescue nil }
+      trap(:USR1) { reopen_worker_logs(worker.nr) }
       trap(:QUIT) { G.quit! }
       [:TERM, :INT].each { |sig| trap(sig) { exit!(0) } } # instant shutdown
       logger.info "Rainbows! #@use worker_connections=#@worker_connections"
diff --git a/lib/rainbows/http_server.rb b/lib/rainbows/http_server.rb
index 0d34d40..a1ec4f6 100644
--- a/lib/rainbows/http_server.rb
+++ b/lib/rainbows/http_server.rb
@@ -18,6 +18,14 @@ module Rainbows
       @worker_connections ||= MODEL_WORKER_CONNECTIONS[@use]
     end
 
+    def reopen_worker_logs(worker_nr)
+      logger.info "worker=#{worker_nr} reopening logs..."
+      Unicorn::Util.reopen_logs
+      logger.info "worker=#{worker_nr} done reopening logs"
+      rescue
+        G.quit! # let the master reopen and refork us
+    end
+
     #:stopdoc:
     #
     # Add one second to the timeout since our fchmod heartbeat is less