From 03b7904f597d80ed7c8e5ae19e2af8d0e0c581ba Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 11 Oct 2009 01:51:27 -0700 Subject: expand and share init_worker_process This can be common across everything --- lib/rainbows/base.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'lib/rainbows/base.rb') diff --git a/lib/rainbows/base.rb b/lib/rainbows/base.rb index da3fff0..2da6d41 100644 --- a/lib/rainbows/base.rb +++ b/lib/rainbows/base.rb @@ -22,6 +22,19 @@ module Rainbows logger.error e.backtrace.join("\n") end + def init_worker_process(worker) + super(worker) + + # 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 } + # closing anything we IO.select on will raise EBADF + trap(:QUIT) { HttpServer::LISTENERS.map! { |s| s.close rescue nil } } + [:TERM, :INT].each { |sig| trap(sig) { exit(0) } } # instant shutdown + logger.info "Rainbows! #@use worker_connections=#@worker_connections" + end + # once a client is accepted, it is processed in its entirety here # in 3 easy steps: read request, call app, write app response def process_client(client) -- cgit v1.2.3-24-ge0c7