about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2014-01-29 21:48:25 +0000
committerEric Wong <normalperson@yhbt.net>2014-01-29 21:48:25 +0000
commita3cb0c37d1e865778a515ccaff4c2af31e556ee1 (patch)
tree9dc4acabd5e1096da37372e5b5927436b12c8a1f
parent2dc55e417708d411987b4fb4233c87fe9f59ba0a (diff)
unicorn 4.8.x shutdown handling is different and no longer removes
items from the event loop.  So we must do that ourselves to enable
graceful shutdown.  Otherwise, we'll time out on shutdowns and
the master will forcibly kill us.
-rw-r--r--lib/rainbows/event_machine.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/rainbows/event_machine.rb b/lib/rainbows/event_machine.rb
index b143b39..b326e26 100644
--- a/lib/rainbows/event_machine.rb
+++ b/lib/rainbows/event_machine.rb
@@ -88,7 +88,17 @@ module Rainbows::EventMachine
         raise RuntimeError, "EM @conns instance variable not accessible!"
       Rainbows::EventMachine::Server.const_set(:CUR, conns)
       Rainbows.at_quit do
-        EM.next_tick { conns.each_value { |c| client_class === c and c.quit } }
+        EM.next_tick do
+          LISTENERS.clear
+          conns.each_value do |c|
+            case c
+            when client_class
+              c.quit
+            when Rainbows::EventMachine::Server
+              c.detach
+            end
+          end
+        end
       end
       EM.add_periodic_timer(1) do
         EM.stop if ! Rainbows.tick && conns.empty? && EM.reactor_running?