From: Ryan Leavengood Date: 2005-08-10T02:44:41+09:00 Subject: Re: drb server using file/tail to read file, and update client? Christopher Aldridge said: > > Any suggestions or am I doing it the only way it can be done? If I understand your problem correctly, the issue is that you now have to constantly poll the server to see if there are more lines, when really what you want is to have the server tell the clients of the new lines. So your options are either to code the clients so they also have a DRb server, which the server connects to when outputting lines from the log file, or possible to use Rinda and a Tuplespace. Here is an example of the former: Server: require 'drb/drb' class TailServer def initialize @clients = [] end def register(uri) puts "Client registered at: #{uri}" @clients << DRbObject.new(nil, uri) end def sendline(line) puts "Sending line: #{line}" @clients.each do |c| c.addline(line) end end end ts = TailServer.new DRb.start_service('druby://localhost:3456', ts) # Obviously the code below needs to be replaced with code # that actually tails the log file i = 0 loop do sleep(5) ts.sendline("This is line #{i}.") i+=1 end DRb.thread.join Client: require 'drb/drb' class TailClient def addline(line) puts line end end # nil in the first parameter opens a random port DRb.start_service(nil, TailClient.new) server = DRbObject.new(nil, 'druby://localhost:3456') server.register(DRb.uri) DRb.thread.join __END__ Ryan