about summary refs log tree commit homepage
path: root/lib/rainbows/http_server.rb
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 /lib/rainbows/http_server.rb
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.
Diffstat (limited to 'lib/rainbows/http_server.rb')
-rw-r--r--lib/rainbows/http_server.rb8
1 files changed, 8 insertions, 0 deletions
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