about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-10-11 01:51:27 -0700
committerEric Wong <normalperson@yhbt.net>2009-10-11 01:51:27 -0700
commit03b7904f597d80ed7c8e5ae19e2af8d0e0c581ba (patch)
tree957914a5e7fd5d197455e056f33aff6b96843d1d
parent427ac38fe3eeadad1d6fb897bd835607a9372aad (diff)
downloadrainbows-03b7904f597d80ed7c8e5ae19e2af8d0e0c581ba.tar.gz
This can be common across everything
-rw-r--r--lib/rainbows/base.rb13
-rw-r--r--lib/rainbows/revactor.rb4
-rw-r--r--lib/rainbows/thread_pool.rb6
-rw-r--r--lib/rainbows/thread_spawn.rb6
4 files changed, 13 insertions, 16 deletions
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)
diff --git a/lib/rainbows/revactor.rb b/lib/rainbows/revactor.rb
index 95cf8fe..006a3b1 100644
--- a/lib/rainbows/revactor.rb
+++ b/lib/rainbows/revactor.rb
@@ -78,10 +78,6 @@ module Rainbows
       init_worker_process(worker)
       alive = worker.tmp # tmp is our lifeline to the master process
 
-      trap(:USR1) { reopen_worker_logs(worker.nr) }
-      trap(:QUIT) { alive = false; LISTENERS.each { |s| s.close rescue nil } }
-      [:TERM, :INT].each { |sig| trap(sig) { exit!(0) } } # instant shutdown
-
       root = Actor.current
       root.trap_exit = true
 
diff --git a/lib/rainbows/thread_pool.rb b/lib/rainbows/thread_pool.rb
index 766742e..033452c 100644
--- a/lib/rainbows/thread_pool.rb
+++ b/lib/rainbows/thread_pool.rb
@@ -24,12 +24,6 @@ module Rainbows
       alive = worker.tmp
       m = 0
 
-      # closing anything we IO.select on will raise EBADF
-      trap(:USR1) { reopen_worker_logs(worker.nr) rescue nil }
-      trap(:QUIT) { LISTENERS.map! { |s| s.close rescue nil } }
-      [:TERM, :INT].each { |sig| trap(sig) { exit(0) } } # instant shutdown
-      logger.info "worker=#{worker.nr} ready with ThreadPool"
-
       while LISTENERS.first && master_pid == Process.ppid
         maintain_thread_count(threads)
         threads.list.each do |thr|
diff --git a/lib/rainbows/thread_spawn.rb b/lib/rainbows/thread_spawn.rb
index 32040ad..ef5d3db 100644
--- a/lib/rainbows/thread_spawn.rb
+++ b/lib/rainbows/thread_spawn.rb
@@ -20,12 +20,6 @@ module Rainbows
       m = 0
       limit = worker_connections
 
-      # closing anything we IO.select on will raise EBADF
-      trap(:USR1) { reopen_worker_logs(worker.nr) rescue nil }
-      trap(:QUIT) { LISTENERS.map! { |s| s.close rescue nil } }
-      [:TERM, :INT].each { |sig| trap(sig) { exit(0) } } # instant shutdown
-      logger.info "worker=#{worker.nr} ready with ThreadSpawn"
-
       begin
         ret = begin
           alive.chmod(m = 0 == m ? 1 : 0)