I need to disconnect explicitly from a druby client.
My code is like:
DRb.start_service @drb = DRbObject.new(nil, ‘druby://localhost:7777’) @drb.dosomething(param1, param2, param3)
…(here I’d like to disconnect!!)…
Background:
I am using druby to communicate between a Rails application running on
lighttpd/FreeBSD6 and a server-script running on the same box with
different
user rights.
I noticed that the longer I run the webserver the more sockets stay
open,
“sockstat | grep ruby” gives me hundreds of:
I need to disconnect explicitly from a druby client.
My code is like:
DRb.start_service @drb = DRbObject.new(nil, ‘druby://localhost:7777’) @drb.dosomething(param1, param2, param3)
…(here I’d like to disconnect!!)…
DRb.stop_service
You can make another call to DRb.start_service if you want to restart
your DRb connection. You’ll have to create another DRbObject, though,
since stop_service terminates all connections.
Background:
I am using druby to communicate between a Rails application running on
lighttpd/FreeBSD6 and a server-script running on the same box with different
user rights.
Martin- I’m doing something similar but using Rinda as a middle man.
What I did was create a singleton class to handle the conenction, one
connection stays open and gets reused.
class SearchClient
private_class_method :new
@@tuple_space = nil
def self.create
if @@tuple_space.nil?
DRb.start_service
@@tuple_space = Rinda::TupleSpaceProxy.new(DRbObject.new(nil,
RINDA_MASTER))
end
@@tuple_space
end
I assume that every time I run the druby client on the website a
connection
remains open. They get all cleared if I restart lighttpd.
Thanks.
martin
He Martin-
You may want to have a look at a rails plugin I wrote called
BackgrounDRb [1]. Its built for this exact purpose. You can have
worker classes that run in the drb server that you can start and stop
from rails. It also has hooks and examples of how to create ajax
progress bars while your workers do their task.