Skip to content

Instantly share code, notes, and snippets.

@tmm1
Created March 17, 2009 20:20
Show Gist options
  • Select an option

  • Save tmm1/80747 to your computer and use it in GitHub Desktop.

Select an option

Save tmm1/80747 to your computer and use it in GitHub Desktop.
diff --git a/lib/nanite/agent.rb b/lib/nanite/agent.rb
index 8cb8900..87da714 100644
--- a/lib/nanite/agent.rb
+++ b/lib/nanite/agent.rb
@@ -178,17 +178,21 @@ module Nanite
def setup_traps
['INT', 'TERM'].each do |sig|
- trap(sig) do
+ old = trap(sig) do
un_register
- EM.add_timer(0.1) do
+ amq.instance_variable_get('@connection').close do
EM.stop
+ old.call if old.is_a? Proc
end
end
end
end
def un_register
- amq.fanout('registration', :no_declare => options[:secure]).publish(serializer.dump(UnRegister.new(identity)))
+ unless @unregistered
+ @unregistered = true
+ amq.fanout('registration', :no_declare => options[:secure]).publish(serializer.dump(UnRegister.new(identity)))
+ end
end
def advertise_services
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment