diff options
Diffstat (limited to 'lib/rainbows')
-rw-r--r-- | lib/rainbows/base.rb | 6 | ||||
-rw-r--r-- | lib/rainbows/revactor.rb | 5 | ||||
-rw-r--r-- | lib/rainbows/thread_pool.rb | 5 | ||||
-rw-r--r-- | lib/rainbows/thread_spawn.rb | 7 |
4 files changed, 10 insertions, 13 deletions
diff --git a/lib/rainbows/base.rb b/lib/rainbows/base.rb index 11c8c7c..da3fff0 100644 --- a/lib/rainbows/base.rb +++ b/lib/rainbows/base.rb @@ -16,6 +16,12 @@ module Rainbows client.close rescue nil end + # TODO: migrate into Unicorn::HttpServer + def listen_loop_error(e) + logger.error "Unhandled listen loop exception #{e.inspect}." + logger.error e.backtrace.join("\n") + 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 3375652..95cf8fe 100644 --- a/lib/rainbows/revactor.rb +++ b/lib/rainbows/revactor.rb @@ -102,10 +102,7 @@ module Rainbows root.link(actor) rescue Errno::EAGAIN, Errno::ECONNABORTED rescue Object => e - if alive - logger.error "Unhandled listen loop exception #{e.inspect}." - logger.error e.backtrace.join("\n") - end + listen_loop_error(e) if alive end while alive end end diff --git a/lib/rainbows/thread_pool.rb b/lib/rainbows/thread_pool.rb index 16a5979..9f1a8db 100644 --- a/lib/rainbows/thread_pool.rb +++ b/lib/rainbows/thread_pool.rb @@ -81,10 +81,7 @@ module Rainbows end end rescue Object => e - if LISTENERS.first - logger.error "Unhandled listen loop exception #{e.inspect}." - logger.error e.backtrace.join("\n") - end + listen_loop_error(e) if LISTENERS.first end while LISTENERS.first } end diff --git a/lib/rainbows/thread_spawn.rb b/lib/rainbows/thread_spawn.rb index 0e023cd..f1acf07 100644 --- a/lib/rainbows/thread_spawn.rb +++ b/lib/rainbows/thread_spawn.rb @@ -45,11 +45,8 @@ module Rainbows end threads.add(Thread.new(c) { |c| process_client(c) }) end - rescue - if alive - logger.error "Unhandled listen loop exception #{e.inspect}." - logger.error e.backtrace.join("\n") - end + rescue Object => e + listen_loop_error(e) if alive end while alive && master_pid == Process.ppid join_spawned_threads(threads) end |