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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 On 8/9/07, Tiberiu Motoc <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > 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 > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 Gopal 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-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---