i'm wondering how can i stop a Rinda ring server, besides killing its process.
i'v checked ring.rb shipped with my ruby 1.9.3, and found the RingServer lacks api to stop itself. It opens an UDPSocket in initialize(), but it dose not contain any code to close that socket.
anybody knows it? thanks ahead. :D
Rinda is part of Distributed Ruby (DRb), so if the goal were to just stop all Rinda and other DRb services, you could do:
If you use that, then in your Rinda service code (the looping method), you need to rescue
DRb::DRbConnErrorto avoid problems trying to write to the TupleSpace, according to: http://www.ruby-forum.com/topic/97023Not a Rinda service, but here is a simple example I tested that stops a DRb service. It just uses DRb (no Rinda) in Ruby 1.9.3, modified slightly from the example here: http://www.ruby-doc.org/stdlib-1.9.3/libdoc/drb/rdoc/DRb.html
server.rb
client.rb
Update: It sounds like you want to monkey patch the ring server to close the socket.
Just create a way to get the existing socket via monkey patch:
Then you can keep the instance of the ringserver in an instance variable, e.g.
@ringserver, and use it to access the socket to close it, set a new socket, etc. e.g.Or skip the attr_accessor and just add a method to RingServer and call a method or two on the RingServer to close, open, bind the socket.
To see how it uses the socket in Ruby 1.9.3: https://github.com/ruby/ruby/blob/v1_9_3_374/lib/rinda/ring.rb