I have installed backgroundrb. I can start it. I have read everything I can get my hands on, and have read the list for a few months. I have written a worker, and am ready to start. This worker reads a queue, and processes it (sends queued emails). Sends 10, sleeps for a minute, sends 10 until done - very straightforward. My question is, what would be the best way to run this? I have assumed a cron like scheduled worker with a named key, but I don?t know. My worker looks like this: class EmailProcessorWorker < BackgrounDRb::Worker::RailsBase def do_work(args) queue = EmailQueue.new queue.process_queue end end EmailProcessorWorker.register I do all the work in a Rails Model, since I can unit test it outside of backgroundrb. Does anyone have a backgroundrb_schedules.yml file I could use as an example, and should this run something like every 15 minutes, etc., or should it start once, and loop endlessly inside do_work? Any thoughts or experience? Thanks for your input ? Jim Scott -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.446 / Virus Database: 268.18.26/746 - Release Date: 4/4/2007 1:09 PM -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20070405/6297ea40/attachment-0001.html
Jim- For a worker like that it shoudl just run all the time in a loop. Have it sleep for x second s and then wake up and process the queue, then sleep again. etc.. Cheers- -Ezra On Apr 5, 2007, at 5:57 PM, Jim Scott wrote:> I have installed backgroundrb. I can start it. I have read > everything I can get my hands on, and have read the list for a few > months. I have written a worker, and am ready to start. > > > > This worker reads a queue, and processes it (sends queued emails). > Sends 10, sleeps for a minute, sends 10 until done - very > straightforward. > > > > My question is, what would be the best way to run this? I have > assumed a cron like scheduled worker with a named key, but I don?t > know. My worker looks like this: > > > > class EmailProcessorWorker < BackgrounDRb::Worker::RailsBase > > def do_work(args) > > queue = EmailQueue.new > > queue.process_queue > > end > > end > > EmailProcessorWorker.register > > > > I do all the work in a Rails Model, since I can unit test it > outside of backgroundrb. > > > > Does anyone have a backgroundrb_schedules.yml file I could use as > an example, and should this run something like every 15 minutes, > etc., or should it start once, and loop endlessly inside do_work? > Any thoughts or experience? > > > > Thanks for your input ? > > > > Jim Scott > > > > > -- > No virus found in this outgoing message. > Checked by AVG Free Edition. > Version: 7.5.446 / Virus Database: 268.18.26/746 - Release Date: > 4/4/2007 1:09 PM > > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel-- Ezra Zygmuntowicz -- Lead Rails Evangelist -- ez at engineyard.com -- Engine Yard, Serious Rails Hosting -- (866) 518-YARD (9273)
Hi Jim, No offense to BackgrounDRb, but you might be better off with creating a class method in Email to find the last 10 (and send ''em), and then use script/runner in a cron job ( you can do every minute easy): the crontab entry might look like: */1 * * * * user /var/www/apps/your_app/script/runner ''EmailQueue.find_and_send_ten()'' cheers! On 4/5/07, Jim Scott <jim.scott at yahoo.com> wrote:> > > > > I have installed backgroundrb. I can start it. I have read everything I > can get my hands on, and have read the list for a few months. I have > written a worker, and am ready to start. > > > > This worker reads a queue, and processes it (sends queued emails). Sends 10, > sleeps for a minute, sends 10 until done - very straightforward. > > > > My question is, what would be the best way to run this? I have assumed a > cron like scheduled worker with a named key, but I don''t know. My worker > looks like this: > > > > class EmailProcessorWorker < BackgrounDRb::Worker::RailsBase > > def do_work(args) > > queue = EmailQueue.new > > queue.process_queue > > end > > end > > EmailProcessorWorker.register > > > > I do all the work in a Rails Model, since I can unit test it outside of > backgroundrb. > > > > Does anyone have a backgroundrb_schedules.yml file I could use as an > example, and should this run something like every 15 minutes, etc., or > should it start once, and loop endlessly inside do_work? Any thoughts or > experience? > > > > Thanks for your input ? > > > > Jim Scott > > > > > -- > No virus found in this outgoing message. > Checked by AVG Free Edition. > Version: 7.5.446 / Virus Database: 268.18.26/746 - Release Date: 4/4/2007 > 1:09 PM > > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel >-- Charles Brian Quinn self-promotion: www.seebq.com highgroove studios: www.highgroove.com slingshot hosting: www.slingshothosting.com main: 678.389.9462 fax: 678.826.0969 Ruby on Rails Bootcamp at the Big Nerd Ranch Intensive Ruby on Rails Training: http://www.bignerdranch.com/classes/ruby.shtml