From 0a0754fc3918b65d0888e3832071086b02e05e97 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 13 Nov 2009 11:10:24 +0000 Subject: gracefully exit workers if reopening logs fails 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. --- lib/rainbows/http_server.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/rainbows/http_server.rb') 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 -- cgit v1.2.3-24-ge0c7