RoR and DRb

Hi,

I have a question regarding RoR and DRb. First of all, I tested with
simple client/server examples and everything worked as expected. I have
the following lines in my environment.rb:
DRb.start_service
$rem_obj = DRbObject.new(nil, “druby://#{rname}:9001”)

Since rem_obj is a global variable, I can call it from any controller
and the invoked procedure is run on the server.

However, what if you want the client to be registered as an observer.
How is that gonna work in rails? I imagine that an observer has to be
running continously, and since rails can only serve page requests how
can it also listen to the server’s events? Do you have to create a
listener object which runs in a separate thread or process?

I actually made this work by adding the following line in the
controller’s initialize() function: DRb.start_service, but I don’t
understand why this works. After the page got served, what process is
still running the observer?

Thanks,
Tiberiu

DRb.start_service (as I understand) spawns a separate thread.

Look at backgroundrb and at Rails observers. I think a combo of them
can do what you want to do.

Vish

Hi Vish,

Thanks for your answer. I did check the drb source code, and indeed
start_service spawns a new thread.
My mistake was that I was starting my client (and the registration of
the observers) without restarting my server(s), and that was causing
some problems. I left start_service in environment.rb and it works.

Tiberiu

Vishnu G. wrote:

DRb.start_service (as I understand) spawns a separate thread.

Look at backgroundrb and at Rails observers. I think a combo of them
can do what you want to do.

Vish