diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-10-10 12:14:25 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-10-10 12:14:25 -0700 |
commit | 5cf2c7d9543a9f25efb69e4693255c52678b0571 (patch) | |
tree | 62573f3498849e4ea391b25cdd658ed728feda8f | |
parent | 4dd4746437380f7971398dd4c6bb12cd5df112f3 (diff) | |
download | rainbows-5cf2c7d9543a9f25efb69e4693255c52678b0571.tar.gz |
Bad stuff happens, even in our own code because sometimes we don't know what we're doing. So log it so we'll know to fix it and let life go on...
-rw-r--r-- | lib/rainbows/thread_spawn.rb | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/rainbows/thread_spawn.rb b/lib/rainbows/thread_spawn.rb index 35a575e..cafdd33 100644 --- a/lib/rainbows/thread_spawn.rb +++ b/lib/rainbows/thread_spawn.rb @@ -26,14 +26,14 @@ module Rainbows [:TERM, :INT].each { |sig| trap(sig) { exit(0) } } # instant shutdown logger.info "worker=#{worker.nr} ready with ThreadSpawn" - while alive && master_pid == Process.ppid + begin ret = begin alive.chmod(m = 0 == m ? 1 : 0) IO.select(LISTENERS, nil, nil, timeout/2.0) or next rescue Errno::EINTR retry rescue Errno::EBADF - alive = false + break end ret.first.each do |l| @@ -47,7 +47,12 @@ module Rainbows end threads.add(Thread.new(c) { |c| process_client(c) }) end - end + rescue + if alive + logger.error "Unhandled listen loop exception #{e.inspect}." + logger.error e.backtrace.join("\n") + end + end while alive && master_pid == Process.ppid join_spawned_threads(threads) end |