I''ve been using script/runner to add and delete files from the database in response to inotify events. This works in theory, but is too slow to keep up with a large number of events in succession; I''m suspecting that the bottleneck is that script/runner has a huge startup cost. One thing I thought of was to queue inotify events, and call script/runner once a minute to clear the queue, but that seems a bit inelegant - ideally, what I''d like to do is have a persistent process that is aware of my rails models, and which I can just keep sending events to and have it process them as they come in. Any thoughts on strategies to accomplish this? martin --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 3 October 2006 14:20, Martin DeMello wrote:> One thing I thought of was to queue inotify events, and call > script/runner once a minute to clear the queue, but that seems a bit > inelegant - ideally, what I''d like to do is have a persistent process > that is aware of my rails models, and which I can just keep sending > events to and have it process them as they come in. Any thoughts on > strategies to accomplish this?You can set up a separate process with DRB server on a well known address/port. Then, you can manage it through DRB. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
An simpler solution might be to use an obfuscated url and a wget cronjob. crontab: * * * * * wget http://localhost/inotify/delete_events/AS4LINAW4>/dev/null 2>&1-- 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 -~----------~----~----~----~------~----~------~--~---
On 10/3/06, Jon Collier <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > An simpler solution might be to use an obfuscated url and a wget > cronjob. > > crontab: > * * * * * wget http://localhost/inotify/delete_events/AS4LINAW4 > >/dev/null 2>&1Won''t that incur the extra overhead of a controller call? All I really need is activerecord and access to the models. I''m trying to do this in realtime (i.e. insert a file into the db as soon as inotify detects it) rather than via a cron job, and I have a feeling that if I can get rid of the script/runner startup time, the rest of the process will be able to keep up nicely. martin --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 10/3/06, Maxim Kulkin <maxim.kulkin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > On 3 October 2006 14:20, Martin DeMello wrote: > > One thing I thought of was to queue inotify events, and call > > script/runner once a minute to clear the queue, but that seems a bit > > inelegant - ideally, what I''d like to do is have a persistent process > > that is aware of my rails models, and which I can just keep sending > > events to and have it process them as they come in. Any thoughts on > > strategies to accomplish this? > > You can set up a separate process with DRB server on a well known > address/port. Then, you can manage it through DRB.Can you point me to some resources on running a DRB server from within my rails app? Everything I''ve seen works the other way, with rails acting as the DRB client. martin --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Thu, Oct 05, 2006 at 12:27:06PM +0530, Martin DeMello wrote:> > On 10/3/06, Maxim Kulkin <maxim.kulkin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > On 3 October 2006 14:20, Martin DeMello wrote: > > > One thing I thought of was to queue inotify events, and call > > > script/runner once a minute to clear the queue, but that seems a bit > > > inelegant - ideally, what I''d like to do is have a persistent process > > > that is aware of my rails models, and which I can just keep sending > > > events to and have it process them as they come in. Any thoughts on > > > strategies to accomplish this? > > > > You can set up a separate process with DRB server on a well known > > address/port. Then, you can manage it through DRB. > > Can you point me to some resources on running a DRB server from within > my rails app? Everything I''ve seen works the other way, with rails > acting as the DRB client.google for the nice backgroundrb plugin. Jens -- Jens Krämer jk-UayuY8ajoWPk1uMJSBkQmQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Martin DeMello wrote:> Won''t that incur the extra overhead of a controller call? All I really > need is activerecord and access to the models. I''m trying to do this > in realtime (i.e. insert a file into the db as soon as inotify detects > it) rather than via a cron job, and I have a feeling that if I can get > rid of the script/runner startup time, the rest of the process will be > able to keep up nicely.While backgroundrb is certainly the most elegant way to go, if you just want access to your model in a script without the whole Rails framework, just write a ruby script and require ActiveRecord and your model. Something like: #!/usr/bin/ruby # require AR and gems require ''rubygems'' require ''active_record'' require ''../app/models/event'' db_config = YAML::load(File.open("../config/database.yml")) ActiveRecord::Base.establish_connection(db_config[''production'']) You can then acccess the Event model as normal. Hope it helps. Alan -- 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 -~----------~----~----~----~------~----~------~--~---
On 10/5/06, Alan Bradburne <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Martin DeMello wrote: > > Won''t that incur the extra overhead of a controller call? All I really > > need is activerecord and access to the models. I''m trying to do this > > in realtime (i.e. insert a file into the db as soon as inotify detects > > it) rather than via a cron job, and I have a feeling that if I can get > > rid of the script/runner startup time, the rest of the process will be > > able to keep up nicely. > > While backgroundrb is certainly the most elegant way to go, if you just > want access to your model in a script without the whole Rails framework, > just write a ruby script and require ActiveRecord and your model. > Something like:[...] Thanks - that worked beautifully. I did have a look at backgroundrb, but I had the same problem with it as with regular drb - as far as I could make out, all the documentation assumed that Rails was running the client, not the server. martin --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I''ve been using script/runner to add and delete files from the database in response to inotify events. This works in theory, but is too slow to keep up with a large number of events in succession; I''m suspecting that the bottleneck is that script/runner has a huge startup cost. One thing I thought of was to queue inotify events, and call script/runner once a minute to clear the queue, but that seems a bit inelegant - ideally, what I''d like to do is have a persistent process that is aware of my rails models, and which I can just keep sending events to and have it process them as they come in. Any thoughts on strategies to accomplish this? martin