From a3cb0c37d1e865778a515ccaff4c2af31e556ee1 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 29 Jan 2014 21:48:25 +0000 Subject: event_machine: update for unicorn 4.8.x 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. --- lib/rainbows/event_machine.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'lib/rainbows/event_machine.rb') 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? -- cgit v1.2.3-24-ge0c7