From info at siebert-wd.de Tue Aug 1 09:32:27 2006 From: info at siebert-wd.de (Michael Siebert) Date: Tue, 1 Aug 2006 15:32:27 +0200 Subject: [Backgroundrb-devel] making backgroundrb cron Message-ID: <32b567370608010632u4f04da02mb632c8f063920f76@mail.gmail.com> Hello, i need to have some jobs scheduled in the background and executed at specific times. I wanted to make a worker who does that - and it works a little bit - but i had an enlightment... why not make bgdrb itself play that role? i mean, the MiddleMan has already everything needed! a timer thread, currently used only for deleting old workers and the workers itself. since im not familiar with threads, are ther some things i could break by adding a few options to backgroundrb.yml and a worker start in the MiddleMan#start_timer? or am i the only one who needs that so comiting it would be senseless? (but i dont think since i have at least two of my projects where i would need such a facility) and if so, how could the configuration be done? best would be something that can be changed and added by runtime while being preserved over various starts and stops... or something of rails magic: class FooWorker < BackgrounDRb::Rails repeat_every 24.hours start_at tomorrow.midnight def do_work @logger.info 'i will appear on midnight every day from now!' end end but since thats magic, i dont really know how that would work, but its more the rails way than an entry in backgroundrb.yml i think what do you think of it? -- Michael Siebert www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060801/965a5544/attachment.html From me at seebq.com Tue Aug 1 09:48:44 2006 From: me at seebq.com (Charles Brian Quinn) Date: Tue, 1 Aug 2006 09:48:44 -0400 Subject: [Backgroundrb-devel] making backgroundrb cron In-Reply-To: <32b567370608010632u4f04da02mb632c8f063920f76@mail.gmail.com> References: <32b567370608010632u4f04da02mb632c8f063920f76@mail.gmail.com> Message-ID: <3a2de0cd0608010648i6fa81668gacb25f2d1e6b280e@mail.gmail.com> Take a look at rails_cron -- however, I'm with you in that you could probably combine these projects easily -- making backgroundrb the system of record. I'm not sure the state of rails_cron development these days. Configuration for rails_cron is a db table and a process that polls every minute. If you commit/patch, I'd be happy to test/contribute as well! -- Charles Brian Quinn self-promotion: www.seebq.com highgroove studios: www.highgroove.com slingshot hosting: www.slingshothosting.com On 8/1/06, Michael Siebert wrote: > Hello, > i need to have some jobs scheduled in the background and executed at > specific times. I wanted to make a worker who does that - and it works a > little bit - but i had an enlightment... why not make bgdrb itself play that > role? i mean, the MiddleMan has already everything needed! a timer thread, > currently used only for deleting old workers and the workers itself. since > im not familiar with threads, are ther some things i could break by adding a > few options to backgroundrb.yml and a worker start in the > MiddleMan#start_timer? or am i the only one who needs that so comiting it > would be senseless? (but i dont think since i have at least two of my > projects where i would need such a facility) > > and if so, how could the configuration be done? best would be something that > can be changed and added by runtime while being preserved over various > starts and stops... or something of rails magic: > > class FooWorker < BackgrounDRb::Rails > repeat_every 24.hours > start_at tomorrow.midnight > > def do_work > @logger.info 'i will appear on midnight every day from now!' > end > end > > but since thats magic, i dont really know how that would work, but its more > the rails way than an entry in backgroundrb.yml i think > > what do you think of it? > > -- > Michael Siebert > > www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel > > From info at siebert-wd.de Tue Aug 1 12:02:28 2006 From: info at siebert-wd.de (Michael Siebert) Date: Tue, 1 Aug 2006 18:02:28 +0200 Subject: [Backgroundrb-devel] Fwd: [PATCH] making backgroundrb cron In-Reply-To: <32b567370608010827r20b9cc36m1faab004d66ffb44@mail.gmail.com> References: <32b567370608010632u4f04da02mb632c8f063920f76@mail.gmail.com> <3a2de0cd0608010648i6fa81668gacb25f2d1e6b280e@mail.gmail.com> <32b567370608010659k57f145c3w9c04f706b67bbbdc@mail.gmail.com> <32b567370608010827r20b9cc36m1faab004d66ffb44@mail.gmail.com> Message-ID: <32b567370608010902q47c63835h84a35d10df86cc93@mail.gmail.com> damn i forgot to cc the list... (thanks charles for telling me) here it is ---------- Forwarded message ---------- From: Michael Siebert Date: 01.08.2006 17:27 Subject: [PATCH] making backgroundrb cron To: Charles Brian Quinn It wasnt a too hard thing to do. Heres the Patch for vendor/plugins/backgroundrb/backgroundrb.rb You declare a worker to be a repetitive one by doing this in your worker class: class FooWorker < BackgrounDRb::Rails repeat 24.hours start_first tomorrow.midnight def do_work @ logger.info 'i will appear on midnight every day from now!' end end now the task is started next midnight and repeated every 24 hours. start_first even takes "17:00" and stuff (everything Time#parse can parse).you should even be able to control thestart time and interval via the methods #next_start and #interval (they're attr_accessors) for me its working perfectly, but a little bit of testing would sure be good did i mention that i love bgdrb more and more every day i find a new thing it can work out for me? -- Michael Siebert < info at siebert-wd.de> www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium -- Michael Siebert www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060801/9b7948a1/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: bgdrbcron.patch Type: application/octet-stream Size: 2100 bytes Desc: not available Url : http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060801/9b7948a1/attachment.obj From info at siebert-wd.de Tue Aug 1 12:08:38 2006 From: info at siebert-wd.de (Michael Siebert) Date: Tue, 1 Aug 2006 18:08:38 +0200 Subject: [Backgroundrb-devel] actionmailer cant find template in backgroundrb Message-ID: <32b567370608010908g6da52d80wba9959f1f1c73cc7@mail.gmail.com> Im trying to send mails from a backgroundrb worker and it seems like ActionView cant find my template. same code works as a rake task. here my worker: class StatusMailWorker < BackgrounDRb::Rails repeat 1.minutes # <-- hehe! def do_work(args) [...blah...] NotificationMailer.create_daily_report(users, rep, items) end end end its throwing the following error: No rhtml, rxml, rjs or delegate template found for daily_report - (ActionView::ActionViewError) d:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_view/base.rb:387:in `find_template_extension_for' d:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_view/base.rb:321:in `pick_template_extension' d:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_view/base.rb:238:in `render_file' d:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_view/base.rb:272:in `render' d:/ruby/lib/ruby/gems/1.8/gems/actionmailer-1.2.3/lib/action_mailer/base.rb:363:in `render' d:/ruby/lib/ruby/gems/1.8/gems/actionmailer-1.2.3/lib/action_mailer/base.rb:358:in `render_message' d:/ruby/lib/ruby/gems/1.8/gems/actionmailer-1.2.3/lib/action_mailer/base.rb:306:in `create!' d:/ruby/lib/ruby/gems/1.8/gems/actionmailer-1.2.3/lib/action_mailer/base.rb:267:in `initialize' d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `new' d:/ruby/lib/ruby/gems/1.8/gems/actionmailer-1.2.3/lib/action_mailer/base.rb:226:in `method_missing' ./script/backgroundrb/../../config/../lib/workers/status_mail_worker.rb:26:in `do_work' <<-- here the mailer is called ./script/backgroundrb/../../config/../lib/workers/status_mail_worker.rb:11:in `do_work' [...] -- Michael Siebert www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060801/3a89e57e/attachment.html From me at seebq.com Tue Aug 1 12:26:39 2006 From: me at seebq.com (Charles Brian Quinn) Date: Tue, 1 Aug 2006 12:26:39 -0400 Subject: [Backgroundrb-devel] actionmailer cant find template in backgroundrb In-Reply-To: <32b567370608010908g6da52d80wba9959f1f1c73cc7@mail.gmail.com> References: <32b567370608010908g6da52d80wba9959f1f1c73cc7@mail.gmail.com> Message-ID: <3a2de0cd0608010926i77094353hd556e7b347fea8a@mail.gmail.com> I *think* my workers had to hit: File.expand_path(File.dirname(__FILE__) + "../../../file.txt")) to load a file in rails_root since they reside in lib/workers, I imagine it might be a similar issue with the mailer.... On 8/1/06, Michael Siebert wrote: > Im trying to send mails from a backgroundrb worker and it seems like > ActionView cant find my template. same code works as a rake task. > here my worker: > > class StatusMailWorker < BackgrounDRb::Rails > repeat 1.minutes # <-- hehe! > > def do_work(args) > [...blah...] > > NotificationMailer.create_daily_report(users, rep, > items) > end > end > > end > > its throwing the following error: > > No rhtml, rxml, rjs or delegate template found for daily_report - > (ActionView::ActionViewError) > d:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_view/base.rb:387:in > `find_template_extension_for' > d:/ruby/lib/ruby/gems/1.8/gems/actionpack- > 1.12.3/lib/action_view/base.rb:321:in `pick_template_extension' > d:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_view/base.rb:238:in > `render_file' > d:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_view/base.rb:272:in > `render' > d:/ruby/lib/ruby/gems/1.8/gems/actionmailer-1.2.3/lib/action_mailer/base.rb:363:in > `render' > d:/ruby/lib/ruby/gems/1.8/gems/actionmailer-1.2.3/lib/action_mailer/base.rb:358:in > `render_message' > d:/ruby/lib/ruby/gems/1.8/gems/actionmailer- > 1.2.3/lib/action_mailer/base.rb:306:in `create!' > d:/ruby/lib/ruby/gems/1.8/gems/actionmailer-1.2.3/lib/action_mailer/base.rb:267:in > `initialize' > d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in > `new' > d:/ruby/lib/ruby/gems/1.8/gems/actionmailer-1.2.3/lib/action_mailer/base.rb:226:in > `method_missing' > ./script/backgroundrb/../../config/../lib/workers/status_mail_worker.rb:26:in > `do_work' <<-- here the mailer is called > ./script/backgroundrb/../../config/../lib/workers/status_mail_worker.rb:11:in > `do_work' > [...] > > -- > Michael Siebert > > www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium > _______________________________________________ > 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 From info at siebert-wd.de Tue Aug 1 13:30:19 2006 From: info at siebert-wd.de (Michael Siebert) Date: Tue, 1 Aug 2006 19:30:19 +0200 Subject: [Backgroundrb-devel] actionmailer cant find template in backgroundrb In-Reply-To: <3a2de0cd0608010926i77094353hd556e7b347fea8a@mail.gmail.com> References: <32b567370608010908g6da52d80wba9959f1f1c73cc7@mail.gmail.com> <3a2de0cd0608010926i77094353hd556e7b347fea8a@mail.gmail.com> Message-ID: <32b567370608011030s25058161qeda934b246748c2e@mail.gmail.com> ahhhh yes thank you 2006/8/1, Charles Brian Quinn : > > I *think* my workers had to hit: > > File.expand_path(File.dirname(__FILE__) + "../../../file.txt")) > > to load a file in rails_root since they reside in lib/workers, I > imagine it might be a similar issue with the mailer.... > > On 8/1/06, Michael Siebert wrote: > > Im trying to send mails from a backgroundrb worker and it seems like > > ActionView cant find my template. same code works as a rake task. > > here my worker: > > > > class StatusMailWorker < BackgrounDRb::Rails > > repeat 1.minutes # <-- hehe! > > > > def do_work(args) > > [...blah...] > > > > NotificationMailer.create_daily_report(users, rep, > > items) > > end > > end > > > > end > > > > its throwing the following error: > > > > No rhtml, rxml, rjs or delegate template found for daily_report - > > (ActionView::ActionViewError) > > d:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3 > /lib/action_view/base.rb:387:in > > `find_template_extension_for' > > d:/ruby/lib/ruby/gems/1.8/gems/actionpack- > > 1.12.3/lib/action_view/base.rb:321:in `pick_template_extension' > > d:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3 > /lib/action_view/base.rb:238:in > > `render_file' > > d:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3 > /lib/action_view/base.rb:272:in > > `render' > > d:/ruby/lib/ruby/gems/1.8/gems/actionmailer-1.2.3 > /lib/action_mailer/base.rb:363:in > > `render' > > d:/ruby/lib/ruby/gems/1.8/gems/actionmailer-1.2.3 > /lib/action_mailer/base.rb:358:in > > `render_message' > > d:/ruby/lib/ruby/gems/1.8/gems/actionmailer- > > 1.2.3/lib/action_mailer/base.rb:306:in `create!' > > d:/ruby/lib/ruby/gems/1.8/gems/actionmailer-1.2.3 > /lib/action_mailer/base.rb:267:in > > `initialize' > > d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in > > `new' > > d:/ruby/lib/ruby/gems/1.8/gems/actionmailer-1.2.3 > /lib/action_mailer/base.rb:226:in > > `method_missing' > > > ./script/backgroundrb/../../config/../lib/workers/status_mail_worker.rb:26:in > > `do_work' <<-- here the mailer is called > > > ./script/backgroundrb/../../config/../lib/workers/status_mail_worker.rb:11:in > > `do_work' > > [...] > > > > -- > > Michael Siebert > > > > www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium > > _______________________________________________ > > 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 > -- Michael Siebert www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060801/9ddd9d89/attachment.html From ezmobius at gmail.com Tue Aug 1 14:59:16 2006 From: ezmobius at gmail.com (Ezra Zygmuntowicz) Date: Tue, 1 Aug 2006 11:59:16 -0700 Subject: [Backgroundrb-devel] [ANN] Update Message-ID: <7D90140C-54E0-426C-A3EA-E7A3948F57BB@gmail.com> Folks- OK there is a new release with some new features in it. The delete_worker method has been refactored to make sure it works with all kinds of workers(thanks Ben Johnson). I touched up the code in quite a few places. I also split the MiddleMan class and the BackgrounDRb::Rails class into their won files since they were getting bigger. Michael Siebert sent some nice patches that have been applied as well. Support for starting workers when the drb server starts up based on config file options and also cron style workers with repeating tasks. **NEW FEATURES** You can now have workers that autostart when the drb server is started, and you can also have cron like workers that run at intervals. To specify a worker to startup when the drb server does you can add something liek this to your backgroundrb.yml config file: autostart: job_key: class: foo_worker args: bar Change job_key to be the actual named key you want to use for this autostart worker. In you workers you can now have timed tasks that repeat themselves at intervals that you set. A simple example looks like this: class CronWorker References: <7D90140C-54E0-426C-A3EA-E7A3948F57BB@gmail.com> Message-ID: <2CA7DA43-98A7-48EA-AA51-417A1593C268@nNovation.ca> Rinda - funny I was just working on integrating this myself. grin. But since you're going ahead I'll head down another dev path I'd rather take at this time. You're likely already further ahead, but I have some code to start a RingServer and and application TupleSpace(attached). It is inspired by the Borges server and Eric Hodel (segment7). Hope it can move you forward. I was intending to build a tuple space proxy into the MiddleMan so I could put/read/take from within rails (I prefer the loosely coupled processing offered by Rinda services). Perhaps after you're finished I can add this capability - I'l likely look for your guidance. Also wanted to note that I tried AutoStart last night, and had real troubles with losing MySql connections (concurrent = false). I'll try again with the latest. Thanx Ezra et al - this is a great project you've got going here. When you announced it a few months ago, I knew it was a keeper. cheers, Jodi On 1-Aug-06, at 2:59 PM, Ezra Zygmuntowicz wrote: > > Folks- -------------- next part -------------- A non-text attachment was scrubbed... Name: launch_rinda.rb Type: text/x-ruby-script Size: 1371 bytes Desc: not available Url : http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060801/5a79dbdf/attachment.bin -------------- next part -------------- > > > OK there is a new release with some new features in it. The > delete_worker method has been refactored to make sure it works with > all kinds of workers(thanks Ben Johnson). I touched up the code in > quite a few places. I also split the MiddleMan class and the > BackgrounDRb::Rails class into their won files since they were > getting bigger. > > Michael Siebert sent some nice patches that have been applied as > well. Support for starting workers when the drb server starts up > based on config file options and also cron style workers with > repeating tasks. > > **NEW FEATURES** > > You can now have workers that autostart when the drb server is > started, and you can also > have cron like workers that run at intervals. To specify a worker to > startup when the > drb server does you can add something liek this to your > backgroundrb.yml config file: > > autostart: > job_key: > class: foo_worker > args: bar > > Change job_key to be the actual named key you want to use for this > autostart worker. > In you workers you can now have timed tasks that repeat themselves at > intervals that you set. > A simple example looks like this: > > class CronWorker > repeat_every 10.minutes > first_run Time.now > > def do_work(args) > @progress ||= 0 > @progress += 1 > end > > def progress > @progress > end > end > > repeat_every takes anything that can be made into a Time object via > Time.parse. Same > thing with first_run. You can use all the nice rails active support > time methods in these > declarations like 2.hours and friends. > > > Michael- I changed the method names for the cron style workers to > something I like a little bit better. So make sure you change your > workers that use the cron stuff to the new syntax. > > > **FUTURE PLANS** > > I am working on a RindaRing server implementation in order to spread > load between multiple drb servers at once. This allwos for multiple > drb servers to easily find each other and share workers. Kind of like > DNS for drb. This way if you have a really burly task you can run it > in it's own ruby process without having to use threading and compete > with other threaded workers for cpu time. This will be a major > overhaul of how things work so it might be released as a separate > plugin, not sure yet though. > > Cheers- > -Ezra > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel From jodi at nNovation.ca Tue Aug 1 17:26:22 2006 From: jodi at nNovation.ca (Jodi Showers) Date: Tue, 1 Aug 2006 17:26:22 -0400 Subject: [Backgroundrb-devel] [ANN] Update In-Reply-To: <7D90140C-54E0-426C-A3EA-E7A3948F57BB@gmail.com> References: <7D90140C-54E0-426C-A3EA-E7A3948F57BB@gmail.com> Message-ID: <093F4A1F-D99B-46D1-811B-CAD06EB8ADC5@nNovation.ca> re: followup to AutoStart and mysql problems. The latest release looks good. Before, I could get a predictable crash quickly - Likely my code. Michael - thanx for the most-excellent cron and autostart contribs. Jodi ---------- Rinda - funny I was just working on integrating this myself. grin. But since you're going ahead I'll head down another dev path I'd rather take at this time. You're likely already further ahead, but I have some code to start a RingServer and and application TupleSpace(attached). It is inspired by the Borges server and Eric Hodel (segment7). Hope it can move you forward. I was intending to build a tuple space proxy into the MiddleMan so I could put/read/take from within rails (I prefer the loosely coupled processing offered by Rinda services). Perhaps after you're finished I can add this capability - I'l likely look for your guidance. Also wanted to note that I tried AutoStart last night, and had real troubles with losing MySql connections (concurrent = false). I'll try again with the latest. Thanx Ezra et al - this is a great project you've got going here. When you announced it a few months ago, I knew it was a keeper. cheers, Jodi On 1-Aug-06, at 2:59 PM, Ezra Zygmuntowicz wrote: > > Folks- -------------- next part -------------- A non-text attachment was scrubbed... Name: launch_rinda.rb Type: text/x-ruby-script Size: 1371 bytes Desc: not available Url : http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060801/3c0b7b8e/attachment.bin -------------- next part -------------- > > > OK there is a new release with some new features in it. The > delete_worker method has been refactored to make sure it works with > all kinds of workers(thanks Ben Johnson). I touched up the code in > quite a few places. I also split the MiddleMan class and the > BackgrounDRb::Rails class into their won files since they were > getting bigger. > > Michael Siebert sent some nice patches that have been applied as > well. Support for starting workers when the drb server starts up > based on config file options and also cron style workers with > repeating tasks. > > **NEW FEATURES** > > You can now have workers that autostart when the drb server is > started, and you can also > have cron like workers that run at intervals. To specify a worker to > startup when the > drb server does you can add something liek this to your > backgroundrb.yml config file: > > autostart: > job_key: > class: foo_worker > args: bar > > Change job_key to be the actual named key you want to use for this > autostart worker. > In you workers you can now have timed tasks that repeat themselves at > intervals that you set. > A simple example looks like this: > > class CronWorker > repeat_every 10.minutes > first_run Time.now > > def do_work(args) > @progress ||= 0 > @progress += 1 > end > > def progress > @progress > end > end > > repeat_every takes anything that can be made into a Time object via > Time.parse. Same > thing with first_run. You can use all the nice rails active support > time methods in these > declarations like 2.hours and friends. > > > Michael- I changed the method names for the cron style workers to > something I like a little bit better. So make sure you change your > workers that use the cron stuff to the new syntax. > > > **FUTURE PLANS** > > I am working on a RindaRing server implementation in order to spread > load between multiple drb servers at once. This allwos for multiple > drb servers to easily find each other and share workers. Kind of like > DNS for drb. This way if you have a really burly task you can run it > in it's own ruby process without having to use threading and compete > with other threaded workers for cpu time. This will be a major > overhaul of how things work so it might be released as a separate > plugin, not sure yet though. > > Cheers- > -Ezra > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel From bjohnson at contuitive.com Tue Aug 1 19:19:45 2006 From: bjohnson at contuitive.com (Ben Johnson) Date: Tue, 1 Aug 2006 18:19:45 -0500 Subject: [Backgroundrb-devel] [ANN] Update In-Reply-To: <7D90140C-54E0-426C-A3EA-E7A3948F57BB@gmail.com> References: <7D90140C-54E0-426C-A3EA-E7A3948F57BB@gmail.com> Message-ID: <0EC7614C-BDD8-41C3-B12D-1C6353B2FA67@contuitive.com> Hi Ezra, Thanks for the update and your hard work. One thing that might be of use (I could use it for my current project), is auto starting workers based on conditions. These conditions would most likely be from the database. Just a thought, because auto starting from yaml is fine, but you are limited in yaml when it comes to database interaction and conditions. Thank You, Ben Johnson E: bjohnson at contuitive.com On Aug 1, 2006, at 1:59 PM, Ezra Zygmuntowicz wrote: > > Folks- > > > OK there is a new release with some new features in it. The > delete_worker method has been refactored to make sure it works with > all kinds of workers(thanks Ben Johnson). I touched up the code in > quite a few places. I also split the MiddleMan class and the > BackgrounDRb::Rails class into their won files since they were > getting bigger. > > Michael Siebert sent some nice patches that have been applied as > well. Support for starting workers when the drb server starts up > based on config file options and also cron style workers with > repeating tasks. > > **NEW FEATURES** > > You can now have workers that autostart when the drb server is > started, and you can also > have cron like workers that run at intervals. To specify a worker to > startup when the > drb server does you can add something liek this to your > backgroundrb.yml config file: > > autostart: > job_key: > class: foo_worker > args: bar > > Change job_key to be the actual named key you want to use for this > autostart worker. > In you workers you can now have timed tasks that repeat themselves at > intervals that you set. > A simple example looks like this: > > class CronWorker > repeat_every 10.minutes > first_run Time.now > > def do_work(args) > @progress ||= 0 > @progress += 1 > end > > def progress > @progress > end > end > > repeat_every takes anything that can be made into a Time object via > Time.parse. Same > thing with first_run. You can use all the nice rails active support > time methods in these > declarations like 2.hours and friends. > > > Michael- I changed the method names for the cron style workers to > something I like a little bit better. So make sure you change your > workers that use the cron stuff to the new syntax. > > > **FUTURE PLANS** > > I am working on a RindaRing server implementation in order to spread > load between multiple drb servers at once. This allwos for multiple > drb servers to easily find each other and share workers. Kind of like > DNS for drb. This way if you have a really burly task you can run it > in it's own ruby process without having to use threading and compete > with other threaded workers for cpu time. This will be a major > overhaul of how things work so it might be released as a separate > plugin, not sure yet though. > > Cheers- > -Ezra > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060801/75e35076/attachment-0001.html From bjohnson at contuitive.com Tue Aug 1 23:44:29 2006 From: bjohnson at contuitive.com (Ben Johnson) Date: Tue, 1 Aug 2006 22:44:29 -0500 Subject: [Backgroundrb-devel] Mysql too many connections Message-ID: <4F4200BF-6472-4FF5-8680-55540BD2E17B@contuitive.com> I wrote an email to the mailing list about this a couple of days ago. But I have new info and need some help. Basically in my background process I am creating new threads. Each thread get's it's own database connection. The problem is that when the thread is finished or killed it doesn't close the connection. What mysql has is a wait_timeout variable. This is set to 8 hours and max_connections is set to 100. I could easily set max_connections to 500 and wait_timeout to 60 seconds or something. This would solve my problem, but as well all know this is a hack. Is there a way to close the db connection when the thread is finished or killed? To make life easier I even kill and clean up my threads through my own method. I just need to know how to close a threads connection from outside of the thread. Thanks for your help. Thank You, Ben Johnson E: bjohnson at contuitive.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060801/2e04af4a/attachment.html From jp at nuance9.com Tue Aug 1 16:36:40 2006 From: jp at nuance9.com (Justin Pease) Date: Tue, 1 Aug 2006 15:36:40 -0500 Subject: [Backgroundrb-devel] Subscribe Message-ID: <3E21584E-DAE7-4F6B-93BE-2B138BC6DCEA@nuance9.com> -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060801/f20e137c/attachment.html From joel at luckyoliver.com Thu Aug 3 17:20:24 2006 From: joel at luckyoliver.com (Joel Hayhurst) Date: Thu, 3 Aug 2006 14:20:24 -0700 Subject: [Backgroundrb-devel] undefined method `[]' for # Message-ID: <4CBF3AEB-9EE1-4943-961A-089615069D67@luckyoliver.com> I tried installing BackgrounDRb today. Followed the readme, made a little worker for myself and executed it within the code. But I keep getting this error. I must've gone over the README a zillion times. Any idea what it is? undefined method `[]' for # From hughes.james at gmail.com Thu Aug 3 17:40:20 2006 From: hughes.james at gmail.com (James Hughes) Date: Thu, 3 Aug 2006 14:40:20 -0700 Subject: [Backgroundrb-devel] undefined method `[]' for # In-Reply-To: <4CBF3AEB-9EE1-4943-961A-089615069D67@luckyoliver.com> References: <4CBF3AEB-9EE1-4943-961A-089615069D67@luckyoliver.com> Message-ID: <765a2c230608031440h70f1135v67548278871efaac@mail.gmail.com> On 8/3/06, Joel Hayhurst wrote: > I tried installing BackgrounDRb today. Followed the readme, made a > little worker for myself and executed it within the code. But I keep > getting this error. I must've gone over the README a zillion times. > Any idea what it is? > > undefined method `[]' for # Hi, I believe that if you are passing any model objects as args to your worker, you need this line somewhere in you model's class definition: include DRbUndumped hth, jh -- James Hughes Web application developer Vancouver, BC "Developing a coherent political analysis is in many respects contingent upon an ability to connect one context to another, a process not dissimilar to playing the kid's game of dot-to-dot." - Ward Churchill, from '"A Government of Laws"?' From ezmobius at gmail.com Thu Aug 3 18:41:34 2006 From: ezmobius at gmail.com (Ezra Zygmuntowicz) Date: Thu, 3 Aug 2006 15:41:34 -0700 Subject: [Backgroundrb-devel] undefined method `[]' for # In-Reply-To: <4CBF3AEB-9EE1-4943-961A-089615069D67@luckyoliver.com> References: <4CBF3AEB-9EE1-4943-961A-089615069D67@luckyoliver.com> Message-ID: On Aug 3, 2006, at 2:20 PM, Joel Hayhurst wrote: > I tried installing BackgrounDRb today. Followed the readme, made a > little worker for myself and executed it within the code. But I keep > getting this error. I must've gone over the README a zillion times. > Any idea what it is? > > undefined method `[]' for # > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel > It looks like you are trying to use one of your models across the wire. What classes are involved in this error? Can you show us your code in rails and in the worker please? I think you will be able to solve this by including DRbUndumpoed in your classes that are involved. So if you have a Post model that you need to send across the wire to a worker then you will need to add this line to the class def: class Post < AR::Base include DRbUndumped end That will fix the DRbUnknown errors for you. -Ezra From joel at luckyoliver.com Thu Aug 3 19:09:25 2006 From: joel at luckyoliver.com (Joel Hayhurst) Date: Thu, 3 Aug 2006 16:09:25 -0700 Subject: [Backgroundrb-devel] undefined method `[]' for # In-Reply-To: References: <4CBF3AEB-9EE1-4943-961A-089615069D67@luckyoliver.com> Message-ID: <6DC53E9F-A01B-4B10-9D82-619AAA9144F5@luckyoliver.com> This did indeed fix the problem, thanks to both of you, Ezra and James! I'll let you know if I have any other issues. On Aug 3, 2006, at 3:41 PM, Ezra Zygmuntowicz wrote: > > On Aug 3, 2006, at 2:20 PM, Joel Hayhurst wrote: > >> I tried installing BackgrounDRb today. Followed the readme, made a >> little worker for myself and executed it within the code. But I keep >> getting this error. I must've gone over the README a zillion times. >> Any idea what it is? >> >> undefined method `[]' for # >> _______________________________________________ >> Backgroundrb-devel mailing list >> Backgroundrb-devel at rubyforge.org >> http://rubyforge.org/mailman/listinfo/backgroundrb-devel >> > > It looks like you are trying to use one of your models across the > wire. What classes are involved in this error? Can you show us your > code in rails and in the worker please? I think you will be able to > solve this by including DRbUndumpoed in your classes that are > involved. So if you have a Post model that you need to send across > the wire to a worker then you will need to add this line to the class > def: > > class Post < AR::Base > include DRbUndumped > > end > > > That will fix the DRbUnknown errors for you. > > -Ezra > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel From info at siebert-wd.de Sat Aug 5 07:38:56 2006 From: info at siebert-wd.de (Michael Siebert) Date: Sat, 5 Aug 2006 13:38:56 +0200 Subject: [Backgroundrb-devel] [PATCH] --detach on win32 Message-ID: <32b567370608050438n32f6307fr2ff9ebfbd9c0e160@mail.gmail.com> Hello there! I made a little patch for scripts/backgroundrb/start to make detach work on win32! It needs win32-process to work (it's a lib from the Win32 Utils project on rubyforge: http://rubyforge.org/projects/win32utils/). To install it, just issue a "gem install win32-process --include-dependencies". If the script detects the :detach option (and a win32 platform), it tries to load 'win32/process', so when that gem isn't installed, it will throw an exception (but there's no need to work around because when it reaches the forks, it will crash nomatterwhat As always, its not tested very well, especially not on *nixes (although it shouldn't affect them), so further testing would be needed. greets -- Michael Siebert www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060805/a6ed6563/attachment.html From lapomme00 at gmail.com Sat Aug 5 13:35:06 2006 From: lapomme00 at gmail.com (Brett Walker) Date: Sun, 6 Aug 2006 01:35:06 +0800 Subject: [Backgroundrb-devel] Creating workers from workers? Message-ID: >On Jul 31, 2006, at 8:05 PM, Ben Johnson wrote: > >> Since MiddleMan is an uninitialized constant in a worker how do you >> create new workers inside a worker? >> >> Thank You, >> Ben Johnson >> E: bjohnson at contuitive.com >> O: 800-341-6826 >> M: 817-229-4258 > > >Ben- > > You would have to use the full module path to the MiddleMan class. >Like this: > >::BackgrounDRb::MiddleMan.new_worker .... > > >-Ezra I need to start a couple workers from one main worker, and I've been trying to get the above to work, to no avail. What exactly do I need to put in my worker file? I had one other quick question: I see mention of @job_ctrl in the code, but I can't find where it's used. Is it no longer needed? Thanks Ezra for a great plugin and all the hard work you do on it. Cheers, Brett From ezmobius at gmail.com Sat Aug 5 16:13:10 2006 From: ezmobius at gmail.com (Ezra Zygmuntowicz) Date: Sat, 5 Aug 2006 13:13:10 -0700 Subject: [Backgroundrb-devel] Creating workers from workers? In-Reply-To: References: Message-ID: On Aug 5, 2006, at 10:35 AM, Brett Walker wrote: >> On Jul 31, 2006, at 8:05 PM, Ben Johnson wrote: >> >>> Since MiddleMan is an uninitialized constant in a worker how do you >>> create new workers inside a worker? >>> >>> Thank You, >>> Ben Johnson >>> E: bjohnson at contuitive.com >>> O: 800-341-6826 >>> M: 817-229-4258 >> >> >> Ben- >> >> You would have to use the full module path to the MiddleMan class. >> Like this: >> >> ::BackgrounDRb::MiddleMan.new_worker .... >> >> >> -Ezra > > I need to start a couple workers from one main worker, and I've been > trying to get the above to work, to no avail. What exactly do I need > to put in my worker file? > > I had one other quick question: I see mention of @job_ctrl in the > code, but I can't find where it's used. Is it no longer needed? > > Thanks Ezra for a great plugin and all the hard work you do on it. > > Cheers, > Brett Hey Brett- Yeah now that I think about it spawning new worker from within a worker won't work like that. The reason being is that when the drb server gets started up it gets a new instance of the MiddleMan class. Like this: DRb.start_service("druby://#{CONFIG['host']}:#{CONFIG['port']}", BackgrounDRb::MiddleMan.new(CONFIG['timer_sleep'] || 60)) This means that in order to reference the new_worker method *in the instance that is running in the drb server* you can't do that directly. In order to spawn other workers from within a worker I would have to change the MiddleMan class to be a singleton. This way you could grab the one instance of it and call new_worker on that and it would work as expected. But the way it is currently setup, you don't have a reference to the Main MiddleMan instance from within your workers. I don't think making the MiddleMan class be a singleton would affect any current code but I will have to test this. If it doesn 't interfere then I think it makes sense to turn the MiddleMan into a singleton. that way you cold gain access to it from within worker classes. And yeah @job_ctr is a leftover. Thanks for spotting that, I will remove it as it currently doesn't do anything. Cheers- -Ezra From ezmobius at gmail.com Sat Aug 5 16:14:03 2006 From: ezmobius at gmail.com (Ezra Zygmuntowicz) Date: Sat, 5 Aug 2006 13:14:03 -0700 Subject: [Backgroundrb-devel] [PATCH] --detach on win32 In-Reply-To: <32b567370608050438n32f6307fr2ff9ebfbd9c0e160@mail.gmail.com> References: <32b567370608050438n32f6307fr2ff9ebfbd9c0e160@mail.gmail.com> Message-ID: <517FCF87-6C85-4E2F-922F-656BD7190A89@gmail.com> On Aug 5, 2006, at 4:38 AM, Michael Siebert wrote: > Hello there! > I made a little patch for scripts/backgroundrb/start to make detach > work on win32! > It needs win32-process to work (it's a lib from the Win32 Utils > project on rubyforge: http://rubyforge.org/projects/win32utils/). > To install it, just issue a "gem install win32-process --include- > dependencies". If the script detects the :detach option (and a > win32 platform), it tries to load 'win32/process', so when that gem > isn't installed, it will throw an exception (but there's no need to > work around because when it reaches the forks, it will crash > nomatterwhat > > As always, its not tested very well, especially not on *nixes > (although it shouldn't affect them), so further testing would be > needed. > > greets > > -- > Michael Siebert < info at siebert-wd.de> > > www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel Hey Michael! This is great, I'm sure the win32 folks will be very happy about this. I'm interested to see it. Did you ofrget to attach the patch when you sent this email out? Thanks- -Ezra -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060805/23c3a900/attachment-0001.html From bjohnson at contuitive.com Sun Aug 6 16:42:52 2006 From: bjohnson at contuitive.com (Ben Johnson) Date: Sun, 6 Aug 2006 15:42:52 -0500 Subject: [Backgroundrb-devel] Debugging a worker? Message-ID: If there is an exception raised in my worker I rescue it and throw it into the log. This is decent, but it would really help to find out more information. Like the line number, the stack trace, etc. Is this possible? Thanks for your help. Thank You, Ben Johnson E: bjohnson at contuitive.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060806/f1d4a33f/attachment.html From ezmobius at gmail.com Sun Aug 6 16:54:09 2006 From: ezmobius at gmail.com (Ezra Zygmuntowicz) Date: Sun, 6 Aug 2006 13:54:09 -0700 Subject: [Backgroundrb-devel] Debugging a worker? In-Reply-To: References: Message-ID: <2AD9CBA2-A8F8-4E8A-9066-D9656E0FFC19@brainspl.at> On Aug 6, 2006, at 1:42 PM, Ben Johnson wrote: > If there is an exception raised in my worker I rescue it and throw > it into the log. This is decent, but it would really help to find > out more information. Like the line number, the stack trace, etc. > Is this possible? > > Thanks for your help. > > Thank You, > Ben Johnson > E: bjohnson at contuitive.com Hey Ben- If I understand what you want I think you can use the same thing I use to rescue and print the stack trace to the log file. Like this in your worker wherever you do a recuse: begin #something that might raise rescue Exception => e @logger.error "#{ e.message } - (#{ e.class })" << "\n" << (e.backtrace or []).join("\n") end Does that help or am I misunderstanding? Cheers- -Ezra -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060806/f8e6903e/attachment.html From funkaster at gmail.com Mon Aug 7 00:18:44 2006 From: funkaster at gmail.com (Rolando Abarca) Date: Mon, 7 Aug 2006 00:18:44 -0400 Subject: [Backgroundrb-devel] problems with ActionMailer Message-ID: <5fccb9940608062118idcd8a3dwbaed51bf1ad376b9@mail.gmail.com> Hi all, I'm trying to create a worker to send a mail to all the users in my db. Right now I'm doing the tests, this is the code in my worker (Masivo is the ActionMailer subclass): def do_work(args) @progress = 0 @logger.info("MAILER: starting job") records = Record.find(:all) total = records.size records.each_with_index do |record, idx| recipients = record.emails.to_a email = Masivo.create_mail_prueba(recipients) email.set_content_type("text/html") Masivo.deliver(email) sleep(10) # this is here for testing purposes end @logger.info("MAILER: job done") @progress = 100 end this is the code in Masivo: def mail_prueba(recipients) @recipients = recipients @from = "myself at mydomain.com" @subject = "test email" @sent_on = Time.now @body = {} end If I do this, I get an exception: No rhtml, rxml, rjs or delegate template found for mail_prueba - (ActionView::ActionViewError) I had to put a render :file at the end of the mail_prueba function, and even that way the email is not sent... Any ideas on what could be the problem? btw... this is the code in the controller that creates the worker: def email_prueba MiddleMan.new_worker(:class => :mailer_worker, :args => "", :job_key => :emailer) redirect_to(:action => 'email_prueba_progress') end def email_prueba_progress render(:text => "Progreso: #{MiddleMan[:emailer].progress}") end thanks for any hint. -- rolando -- [[ knowledge is empty, fill it ]] -- "Tam pro papa quam pro rege bibunt omnes sine lege." From me at seebq.com Mon Aug 7 00:34:41 2006 From: me at seebq.com (Charles Brian Quinn) Date: Mon, 7 Aug 2006 00:34:41 -0400 Subject: [Backgroundrb-devel] problems with ActionMailer In-Reply-To: <5fccb9940608062118idcd8a3dwbaed51bf1ad376b9@mail.gmail.com> References: <5fccb9940608062118idcd8a3dwbaed51bf1ad376b9@mail.gmail.com> Message-ID: <3a2de0cd0608062134t3c375252j410ef6396aeef202@mail.gmail.com> Your workers reside in lib/workers, which means the path for them back to RAILS_ROOT is back two levels, and thus the mail templates are back two as well: File.expand_path(File.dirname(__FILE__) + "../../../file.txt")) see: http://rubyforge.org/pipermail/backgroundrb-devel/2006-August/000163.html posted just a few days ago.... -- Charles Brian Quinn self-promotion: www.seebq.com highgroove studios: www.highgroove.com slingshot hosting: www.slingshothosting.com On 8/7/06, Rolando Abarca wrote: > Hi all, > I'm trying to create a worker to send a mail to all the users in my > db. Right now I'm doing the tests, this is the code in my worker > (Masivo is the ActionMailer subclass): > > def do_work(args) > @progress = 0 > @logger.info("MAILER: starting job") > records = Record.find(:all) > total = records.size > records.each_with_index do |record, idx| > recipients = record.emails.to_a > email = Masivo.create_mail_prueba(recipients) > email.set_content_type("text/html") > Masivo.deliver(email) > sleep(10) # this is here for testing purposes > end > @logger.info("MAILER: job done") > @progress = 100 > end > > this is the code in Masivo: > > def mail_prueba(recipients) > @recipients = recipients > @from = "myself at mydomain.com" > @subject = "test email" > @sent_on = Time.now > @body = {} > end > > If I do this, I get an exception: > > No rhtml, rxml, rjs or delegate template found for mail_prueba - > (ActionView::ActionViewError) > > I had to put a render :file at the end of the mail_prueba function, > and even that way the email is not sent... Any ideas on what could be > the problem? > > btw... this is the code in the controller that creates the worker: > > def email_prueba > MiddleMan.new_worker(:class => :mailer_worker, :args => "", > :job_key => :emailer) > redirect_to(:action => 'email_prueba_progress') > end > > def email_prueba_progress > render(:text => "Progreso: #{MiddleMan[:emailer].progress}") > end > > thanks for any hint. > -- > rolando -- [[ knowledge is empty, fill it ]] -- > "Tam pro papa quam pro rege bibunt omnes sine lege." > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel > From lapomme00 at gmail.com Mon Aug 7 03:43:24 2006 From: lapomme00 at gmail.com (Brett Walker) Date: Mon, 7 Aug 2006 15:43:24 +0800 Subject: [Backgroundrb-devel] Debugging a worker? In-Reply-To: <2AD9CBA2-A8F8-4E8A-9066-D9656E0FFC19@brainspl.at> References: <2AD9CBA2-A8F8-4E8A-9066-D9656E0FFC19@brainspl.at> Message-ID: Ezra, this helped me. Thanks. You mentioned once that you were going to put in support for breakpoint. Is that still on the table? Cheers, Brett On 8/7/06, Ezra Zygmuntowicz wrote: > > > > On Aug 6, 2006, at 1:42 PM, Ben Johnson wrote: > > If there is an exception raised in my worker I rescue it and throw it into > the log. This is decent, but it would really help to find out more > information. Like the line number, the stack trace, etc. Is this possible? > > Thanks for your help. > > Thank You, > Ben Johnson > E: bjohnson at contuitive.com > > > Hey Ben- > > If I understand what you want I think you can use the same thing I use to > rescue and print the stack trace to the log file. Like this in your worker > wherever you do a recuse: > > begin > #something that might raise > rescue Exception => e > @logger.error "#{ e.message } - (#{ e.class })" << "\n" << > (e.backtrace or []).join("\n") > end > > Does that help or am I misunderstanding? > > Cheers- > -Ezra > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel > > From lapomme00 at gmail.com Mon Aug 7 03:49:51 2006 From: lapomme00 at gmail.com (Brett Walker) Date: Mon, 7 Aug 2006 15:49:51 +0800 Subject: [Backgroundrb-devel] problems with ActionMailer In-Reply-To: <3a2de0cd0608062134t3c375252j410ef6396aeef202@mail.gmail.com> References: <5fccb9940608062118idcd8a3dwbaed51bf1ad376b9@mail.gmail.com> <3a2de0cd0608062134t3c375252j410ef6396aeef202@mail.gmail.com> Message-ID: On 8/7/06, Charles Brian Quinn wrote: > Your workers reside in lib/workers, which means the path for them back > to RAILS_ROOT is back two levels, and thus the mail templates are back > two as well: > > File.expand_path(File.dirname(__FILE__) + "../../../file.txt")) > > see: http://rubyforge.org/pipermail/backgroundrb-devel/2006-August/000163.html > > posted just a few days ago.... > -- > Charles Brian Quinn Charles, I read the referenced post a couple of days ago, and I still don't understand it. Are you saying that we need to use render :file and your File.expand line? I guess I didn't understand how you actually use it to get the email sent (sorry, I can be a bit dense sometimes). Cheers, Brett From lapomme00 at gmail.com Mon Aug 7 03:57:57 2006 From: lapomme00 at gmail.com (Brett Walker) Date: Mon, 7 Aug 2006 15:57:57 +0800 Subject: [Backgroundrb-devel] Creating workers from workers? In-Reply-To: References: Message-ID: On 8/6/06, Ezra Zygmuntowicz wrote: > > On Aug 5, 2006, at 10:35 AM, Brett Walker wrote: > > >> On Jul 31, 2006, at 8:05 PM, Ben Johnson wrote: > >> > >>> Since MiddleMan is an uninitialized constant in a worker how do you > >>> create new workers inside a worker? > >>> > >>> Thank You, > >>> Ben Johnson > >>> E: bjohnson at contuitive.com > >>> O: 800-341-6826 > >>> M: 817-229-4258 > >> > >> > >> Ben- > >> > >> You would have to use the full module path to the MiddleMan class. > >> Like this: > >> > >> ::BackgrounDRb::MiddleMan.new_worker .... > >> > >> > >> -Ezra > > > > I need to start a couple workers from one main worker, and I've been > > trying to get the above to work, to no avail. What exactly do I need > > to put in my worker file? > > > > I had one other quick question: I see mention of @job_ctrl in the > > code, but I can't find where it's used. Is it no longer needed? > > > > Thanks Ezra for a great plugin and all the hard work you do on it. > > > > Cheers, > > Brett > > > Hey Brett- > > Yeah now that I think about it spawning new worker from within a > worker won't work like that. The reason being is that when the drb > server gets started up it gets a new instance of the MiddleMan class. > Like this: > > > DRb.start_service("druby://#{CONFIG['host']}:#{CONFIG['port']}", > BackgrounDRb::MiddleMan.new(CONFIG['timer_sleep'] || 60)) > > > This means that in order to reference the new_worker method *in the > instance that is running in the drb server* you can't do that > directly. In order to spawn other workers from within a worker I > would have to change the MiddleMan class to be a singleton. This way > you could grab the one instance of it and call new_worker on that and > it would work as expected. But the way it is currently setup, you > don't have a reference to the Main MiddleMan instance from within > your workers. > > I don't think making the MiddleMan class be a singleton would affect > any current code but I will have to test this. If it doesn > 't interfere then I think it makes sense to turn the MiddleMan into a > singleton. that way you cold gain access to it from within worker > classes. > > And yeah @job_ctr is a leftover. Thanks for spotting that, I will > remove it as it currently doesn't do anything. > > > Cheers- > -Ezra > > I would love to see the singelton ability make it in. I prefer not to have to start workers from workers (just an extra complication), but I need to be able to do some ongoing performance measurements, and this would allow me to deal with it in one place. Cheers, Brett From lapomme00 at gmail.com Mon Aug 7 04:33:03 2006 From: lapomme00 at gmail.com (Brett Walker) Date: Mon, 7 Aug 2006 16:33:03 +0800 Subject: [Backgroundrb-devel] Process status... Message-ID: I've used Railscron in a couple instances, and I liked that fact that it has a rake task for checking the status of the process. Many times I use it in the admin interface to allow me to double check that everything is up and running. I couldn't find one for backgroundrb, so here is a simple one. Probably obvious to everyone, and no doubt there is a better way to do it: namespace :backgroundrb do desc "Status of BackgrounDRb" task :status do puts `ps x | grep backgroundrb | grep -v backgroundrb:status | grep -v grep` end end If there is another way I don't know about, please let me know. Cheers, Brett From lapomme00 at gmail.com Mon Aug 7 06:07:10 2006 From: lapomme00 at gmail.com (Brett Walker) Date: Mon, 7 Aug 2006 18:07:10 +0800 Subject: [Backgroundrb-devel] Process status... In-Reply-To: <32b567370608070148m1f4b6977j6399fcc9b1e897d4@mail.gmail.com> References: <32b567370608070148m1f4b6977j6399fcc9b1e897d4@mail.gmail.com> Message-ID: Totally agree. It would be great to see the status of all the jobs. The simple solution is all I needed right now, but I can see building out a more detailed status screen, and would need this level of function. Also being able to set up an email notify if a critical process drops for some reason. Cheers, Brett On 8/7/06, Michael Siebert wrote: > nice. but there could be another way, involving more code, but then it > should be even possible to determine what workers are loaded, who is > currently working, and other status stuff. and it would be > platform-independent. as i could need that in some time too, i'll check if > that works what i have in my mind... (if i can find some time on the > road...) > > > 2006/8/7, Brett Walker : > > > I've used Railscron in a couple instances, and I liked that fact that > it has a rake task for checking the status of the process. Many times > I use it in the admin interface to allow me to double check that > everything is up and running. > > I couldn't find one for backgroundrb, so here is a simple one. > Probably obvious to everyone, and no doubt there is a better way to do > it: > > namespace :backgroundrb do > desc "Status of BackgrounDRb" > task :status do > puts `ps x | grep backgroundrb | grep -v backgroundrb:status | > grep -v grep` > end > end > > If there is another way I don't know about, please let me know. > > Cheers, > Brett > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel > > > > -- > Michael Siebert > > www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium From lapomme00 at gmail.com Mon Aug 7 07:27:56 2006 From: lapomme00 at gmail.com (Brett Walker) Date: Mon, 7 Aug 2006 19:27:56 +0800 Subject: [Backgroundrb-devel] Autostarting and job keys... Message-ID: I've now got 5 processes auto started. But I when I query the MiddleMan for their keys (in script/console), it doesn't find them. Looking at the start script, it looks like it might be creating a new MiddleMan object for each autostart BackgrounDRb::MiddleMan.new.new_worker(:class => entry['class'], Even changing it to BackgrounDRb::MiddleMan.new_worker(:class => entry['class'], didn't seem to take care of it. I even tried to create a single MiddleMan and pass that to autostart, still to no avail. Is there a way to have the autostarted jobs be manages by the main MiddleMan object? Cheers, Brett From me at seebq.com Mon Aug 7 07:28:54 2006 From: me at seebq.com (Charles Brian Quinn) Date: Mon, 7 Aug 2006 07:28:54 -0400 Subject: [Backgroundrb-devel] problems with ActionMailer In-Reply-To: References: <5fccb9940608062118idcd8a3dwbaed51bf1ad376b9@mail.gmail.com> <3a2de0cd0608062134t3c375252j410ef6396aeef202@mail.gmail.com> Message-ID: <3a2de0cd0608070428p1d8035c4xe2d6ace9b9ef63d1@mail.gmail.com> If you are only using this mailer for mail sent from a worker, you can use in your main mail initializing block (your sent method): @subject = blah @recipients = blah @body = blah @template = "../../path/to/template" # instead of ./path/to/template http://railsmanual.com/class/ActionMailer::Base On 8/7/06, Brett Walker wrote: > On 8/7/06, Charles Brian Quinn wrote: > > Your workers reside in lib/workers, which means the path for them back > > to RAILS_ROOT is back two levels, and thus the mail templates are back > > two as well: > > > > File.expand_path(File.dirname(__FILE__) + "../../../file.txt")) > > > > see: http://rubyforge.org/pipermail/backgroundrb-devel/2006-August/000163.html > > > > posted just a few days ago.... > > -- > > Charles Brian Quinn > > Charles, I read the referenced post a couple of days ago, and I still > don't understand it. Are you saying that we need to use render :file > and your File.expand line? I guess I didn't understand how you > actually use it to get the email sent (sorry, I can be a bit dense > sometimes). > > Cheers, > Brett > _______________________________________________ > 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 From lapomme00 at gmail.com Mon Aug 7 07:49:14 2006 From: lapomme00 at gmail.com (Brett Walker) Date: Mon, 7 Aug 2006 19:49:14 +0800 Subject: [Backgroundrb-devel] repeat_every doesn't tie in with first_run... Message-ID: Ezra, Sorry for inundating the list. In using the autostart, repeat_every, and first_run, I noticed a behaviour I didn't expect. I would like the job to run starting at 2am, and then every 24 hours. So I set first_run to Time.now.beginning_of_day + 2.hours, and repeat_every to 24.hours. The problem is if backgroundrb starts up at 6am (due to a code change or server bump), then the process runs immediately (because first_run < Time.now), and then runs every 24 hours from that time, so 6am every day. I was expecting more cron-ish behaviour, where it would start at the first_run time and repeat based on that initial time. Is this the proper behaviour? Personally, I like the cron style better - it gives me tighter control, which might be required for better resource utilization. If I want it to start running immediatley, I can put in first_run Time.now. Thoughts? Cheers, Brett From info at siebert-wd.de Mon Aug 7 08:02:30 2006 From: info at siebert-wd.de (Michael Siebert) Date: Mon, 7 Aug 2006 14:02:30 +0200 Subject: [Backgroundrb-devel] repeat_every doesn't tie in with first_run... In-Reply-To: References: Message-ID: <32b567370608070502x225f2ffem7b54e5483b3b9eca@mail.gmail.com> That Behaviour is absolutely OK, since it starts the job when Time.now > first_start. Time.now.beginning_of_day is 0:00 TODAY, meaning 14 hours ago (at least here in Germany). The only way to work around that is to use Time.now.tomorrow.beginning_of_day meaning 0:00 tonight. I think this can be improved in some later version. 2006/8/7, Brett Walker : > > Ezra, > > Sorry for inundating the list. In using the autostart, repeat_every, > and first_run, I noticed a behaviour I didn't expect. > > I would like the job to run starting at 2am, and then every 24 hours. > So I set first_run to Time.now.beginning_of_day + 2.hours, and > repeat_every to 24.hours. > > The problem is if backgroundrb starts up at 6am (due to a code change > or server bump), then the process runs immediately (because first_run > < Time.now), and then runs every 24 hours from that time, so 6am every > day. I was expecting more cron-ish behaviour, where it would start at > the first_run time and repeat based on that initial time. > > Is this the proper behaviour? Personally, I like the cron style > better - it gives me tighter control, which might be required for > better resource utilization. If I want it to start running > immediatley, I can put in first_run Time.now. > > Thoughts? > > Cheers, > Brett > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel > -- Michael Siebert www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060807/c2479aa9/attachment.html From lapomme00 at gmail.com Mon Aug 7 09:29:19 2006 From: lapomme00 at gmail.com (Brett Walker) Date: Mon, 7 Aug 2006 21:29:19 +0800 Subject: [Backgroundrb-devel] repeat_every doesn't tie in with first_run... In-Reply-To: <32b567370608070502x225f2ffem7b54e5483b3b9eca@mail.gmail.com> References: <32b567370608070502x225f2ffem7b54e5483b3b9eca@mail.gmail.com> Message-ID: Hhhmm...I still disagree. A 24 hour cycle was not a good example. Suppose I want it run every 6 hours. 2am, 8am, 2pm, 8pm. Since we don't know when backgroundrb is going to be started, it's a convuluted calculation for first_run to line up with one of the run times, unless you put it at 2am tomorrow. But that means it doesn't run at all today. The best way is to set it to 2am today, and calculate the period based off of the start time. Railscron takes care of it like this: def should_run_now now = Time.now.to_i return false if self.start && self.start > now return false if self.finish && self.finish < now start = self.start every = self.every || 1.day proximity = (now - start) % every return proximity < @@options[:sleep] end The difference between Time.now and the start time modded with the period. As long as the remainder falls within the sleep period, it kicks off. Your going to get within @@options[:sleep] seconds of the real time you wanted. Cheers, Brett On 8/7/06, Michael Siebert wrote: > That Behaviour is absolutely OK, since it starts the job when Time.now > > first_start. Time.now.beginning_of_day is 0:00 TODAY, meaning 14 hours ago > (at least here in Germany). The only way to work around that is to use > Time.now.tomorrow.beginning_of_day meaning 0:00 tonight. I > think this can be improved in some later version. > > > 2006/8/7, Brett Walker : > > > Ezra, > > Sorry for inundating the list. In using the autostart, repeat_every, > and first_run, I noticed a behaviour I didn't expect. > > I would like the job to run starting at 2am, and then every 24 hours. > So I set first_run to Time.now.beginning_of_day + 2.hours, and > repeat_every to 24.hours. > > The problem is if backgroundrb starts up at 6am (due to a code change > or server bump), then the process runs immediately (because first_run > < Time.now), and then runs every 24 hours from that time, so 6am every > day. I was expecting more cron-ish behaviour, where it would start at > the first_run time and repeat based on that initial time. > > Is this the proper behaviour? Personally, I like the cron style > better - it gives me tighter control, which might be required for > better resource utilization. If I want it to start running > immediatley, I can put in first_run Time.now. > > Thoughts? > > Cheers, > Brett > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel > > > > -- > Michael Siebert > > www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium From marc.beyerlin at combots.com Mon Aug 7 10:14:21 2006 From: marc.beyerlin at combots.com (Marc Beyerlin) Date: Mon, 7 Aug 2006 16:14:21 +0200 Subject: [Backgroundrb-devel] uninitialized constants in worker class Message-ID: <9E2A3DE383A4D94B9C7AAC5F1763B82F3B7E16@CBKA0018.intern.combots.com> I am new to this list and relatively new to the backgroundrb plugin,. So first i will say hello to everybody here, especially to Ezra Zygmuntowicz! I played a little bit with a dummy worker and so far everything worked well. But now i want to do real work in a worker but now i get that error[1]. It looks like that the constants configured in environment* configs are not available to the worker class. My configuration looks like that[2]. Maybe someone can give me a hint to solve this problem. Greetz, Marc Beyerlin [1] backgroundrb.log: uninitialized constant SYSTEM_AMS_AVAILABLE - (NameError) ./script/backgroundrb/../../config/../vendor/rails/activerecord/lib/../. ./activesupport/lib/active_support/dependencies.rb:123:in `const_missing' ./script/backgroundrb/../../config/../components/ams_import.rb:56:in `get_published_ams_ids' ./script/backgroundrb/../../config/../lib/workers/warehouse.rb:8:in `do_work' ./script/backgroundrb/../../config/../vendor/plugins/backgroundrb/backgr oundrb.rb:45:in `start_process' ./script/backgroundrb/../../config/../vendor/plugins/backgroundrb/backgr oundrb.rb:41:in `start_process' ./script/backgroundrb/../../config/../vendor/plugins/backgroundrb/backgr oundrb.rb:112:in `new_worker' C:/Programme/ruby/lib/ruby/1.8/thread.rb:135:in `synchronize' ./script/backgroundrb/../../config/../vendor/plugins/backgroundrb/backgr oundrb.rb:104:in `new_worker' C:/Programme/ruby/lib/ruby/1.8/drb/drb.rb:1552:in `perform_without_block' C:/Programme/ruby/lib/ruby/1.8/drb/drb.rb:1512:in `perform' C:/Programme/ruby/lib/ruby/1.8/drb/drb.rb:1586:in `main_loop' C:/Programme/ruby/lib/ruby/1.8/drb/drb.rb:1582:in `main_loop' C:/Programme/ruby/lib/ruby/1.8/drb/drb.rb:1578:in `main_loop' C:/Programme/ruby/lib/ruby/1.8/drb/drb.rb:1427:in `run' C:/Programme/ruby/lib/ruby/1.8/drb/drb.rb:1424:in `run' C:/Programme/ruby/lib/ruby/1.8/drb/drb.rb:1344:in `initialize' C:/Programme/ruby/lib/ruby/1.8/drb/drb.rb:1624:in `start_service' script/backgroundrb/start:84 [2] background.yml port: "22222" timer_sleep: 60 load_rails: true environment: development host: localhost database_yml: config/database.yml acl: deny: all allow: localhost 127.0.0.1 order: deny,allow From lapomme00 at gmail.com Mon Aug 7 10:24:42 2006 From: lapomme00 at gmail.com (Brett Walker) Date: Mon, 7 Aug 2006 22:24:42 +0800 Subject: [Backgroundrb-devel] Autostarting and job keys... In-Reply-To: References: Message-ID: I think I've got it figured out. Turns out I was mucking with the plugin's start.rake instead of the one in scripts/backgroundrb. My idea seems to work. In the 2 places where this line exits DRb.start_service("druby://#{CONFIG['host']}:#{CONFIG['port']}", BackgrounDRb::MiddleMan.new(CONFIG['timer_sleep'] || 60)) replace with middle_man = BackgrounDRb::MiddleMan.new(CONFIG['timer_sleep'] || 60) DRb.start_service("druby://#{CONFIG['host']}:#{CONFIG['port']}", middle_man) This keeps the middle man that was created and attached to the DRb service. Now we pass that into Auto.start Auto.start(middle_man) and use it to autostart the jobs def self.start(middle_man) ....... middle_man.new_worker(:class => entry['class'], :args => entry['args'], :job_key => key) This gives me access to the jobs via the MiddleMan in my application. Does this seem safe and a valid fix? Cheers, Brett On 8/7/06, Brett Walker wrote: > I've now got 5 processes auto started. But I when I query the > MiddleMan for their keys (in script/console), it doesn't find them. > Looking at the start script, it looks like it might be creating a new > MiddleMan object for each autostart > > BackgrounDRb::MiddleMan.new.new_worker(:class => entry['class'], > > Even changing it to > > BackgrounDRb::MiddleMan.new_worker(:class => entry['class'], > > didn't seem to take care of it. I even tried to create a single > MiddleMan and pass that to autostart, still to no avail. > > Is there a way to have the autostarted jobs be manages by the main > MiddleMan object? > > Cheers, > Brett > From funkaster at gmail.com Mon Aug 7 00:16:31 2006 From: funkaster at gmail.com (Rolando Abarca) Date: Mon, 7 Aug 2006 00:16:31 -0400 Subject: [Backgroundrb-devel] problems with ActionMailer Message-ID: <5fccb9940608062116yed2c774k17261a21bd2a4790@mail.gmail.com> Hi all, I'm trying to create a worker to send a mail to all the users in my db. Right now I'm doing the tests, this is the code in my worker (Masivo is the ActionMailer subclass): def do_work(args) @progress = 0 @logger.info("MAILER: starting job") records = Record.find(:all) total = records.size records.each_with_index do |record, idx| recipients = record.emails.to_a email = Masivo.create_mail_prueba(recipients) email.set_content_type("text/html") Masivo.deliver(email) sleep(10) # this is here for testing purposes end @logger.info("MAILER: job done") @progress = 100 end this is the code in Masivo: def mail_prueba(recipients) @recipients = recipients @from = "myself at mydomain.com" @subject = "test email" @sent_on = Time.now @body = {} end If I do this, I get an exception: No rhtml, rxml, rjs or delegate template found for mail_prueba - (ActionView::ActionViewError) I had to put a render :file at the end of the mail_prueba function, and even that way the email is not sent... Any ideas on what could be the problem? btw... this is the code in the controller that creates the worker: def email_prueba MiddleMan.new_worker(:class => :mailer_worker, :args => "", :job_key => :emailer) redirect_to(:action => 'email_prueba_progress') end def email_prueba_progress render(:text => "Progreso: #{MiddleMan[:emailer].progress}") end thanks for any hint. -- rolando -- [[ knowledge is empty, fill it ]] -- "Tam pro papa quam pro rege bibunt omnes sine lege." From funkaster at gmail.com Mon Aug 7 11:13:36 2006 From: funkaster at gmail.com (Rolando Abarca) Date: Mon, 7 Aug 2006 11:13:36 -0400 Subject: [Backgroundrb-devel] problems with ActionMailer In-Reply-To: <5fccb9940608070811g204c2efcu4e27aa9c66dc1dc9@mail.gmail.com> References: <5fccb9940608062118idcd8a3dwbaed51bf1ad376b9@mail.gmail.com> <3a2de0cd0608062134t3c375252j410ef6396aeef202@mail.gmail.com> <3a2de0cd0608070428p1d8035c4xe2d6ace9b9ef63d1@mail.gmail.com> <5fccb9940608070811g204c2efcu4e27aa9c66dc1dc9@mail.gmail.com> Message-ID: <5fccb9940608070813n73d7d029x79e7d2b55874c942@mail.gmail.com> On 8/7/06, Charles Brian Quinn wrote: > If you are only using this mailer for mail sent from a worker, you can > use in your main mail initializing block (your sent method): > > @subject = blah > @recipients = blah > @body = blah > @template = "../../path/to/template" # instead of ./path/to/template Ok, I got the idea (I think), but it still not working. My mail views are in the default directory (app/views/masivo/) So I set @template to this: @template = "../../app/views/masivo/mail_prueba" (and i've restarted the rails app and the backgroundrb server) is this the way it should be? I'm a bit confused... :-S -- rolando -- [[ knowledge is empty, fill it ]] -- "Tam pro papa quam pro rege bibunt omnes sine lege." From ezmobius at gmail.com Mon Aug 7 11:15:16 2006 From: ezmobius at gmail.com (Ezra Zygmuntowicz) Date: Mon, 7 Aug 2006 08:15:16 -0700 Subject: [Backgroundrb-devel] repeat_every doesn't tie in with first_run... In-Reply-To: References: <32b567370608070502x225f2ffem7b54e5483b3b9eca@mail.gmail.com> Message-ID: Yeah I agree with Brett. If we are going to have a start time like we do we ought to be calculating the intervals so they line up to the correct time. Perhaps I can steal that method from rails cron ;) I hope to have some time later today to work on the plugin. I have a few features lined up that I need to release. I will add this to the list and see what I can come up with. Cheers- -Ezra On Aug 7, 2006, at 6:29 AM, Brett Walker wrote: > Hhhmm...I still disagree. A 24 hour cycle was not a good example. > Suppose I want it run every 6 hours. 2am, 8am, 2pm, 8pm. Since we > don't know when backgroundrb is going to be started, it's a convuluted > calculation for first_run to line up with one of the run times, unless > you put it at 2am tomorrow. But that means it doesn't run at all > today. > > The best way is to set it to 2am today, and calculate the period based > off of the start time. Railscron takes care of it like this: > > def should_run_now > now = Time.now.to_i > return false if self.start && self.start > now > return false if self.finish && self.finish < now > > start = self.start > every = self.every || 1.day > proximity = (now - start) % every > return proximity < @@options[:sleep] > end > > The difference between Time.now and the start time modded with the > period. As long as the remainder falls within the sleep period, it > kicks off. Your going to get within @@options[:sleep] seconds of the > real time you wanted. > > Cheers, > Brett > > On 8/7/06, Michael Siebert wrote: >> That Behaviour is absolutely OK, since it starts the job when >> Time.now > >> first_start. Time.now.beginning_of_day is 0:00 TODAY, meaning 14 >> hours ago >> (at least here in Germany). The only way to work around that is to >> use >> Time.now.tomorrow.beginning_of_day meaning 0:00 tonight. I >> think this can be improved in some later version. >> >> >> 2006/8/7, Brett Walker : >>> >> Ezra, >> >> Sorry for inundating the list. In using the autostart, repeat_every, >> and first_run, I noticed a behaviour I didn't expect. >> >> I would like the job to run starting at 2am, and then every 24 hours. >> So I set first_run to Time.now.beginning_of_day + 2.hours, and >> repeat_every to 24.hours. >> >> The problem is if backgroundrb starts up at 6am (due to a code change >> or server bump), then the process runs immediately (because first_run >> < Time.now), and then runs every 24 hours from that time, so 6am >> every >> day. I was expecting more cron-ish behaviour, where it would >> start at >> the first_run time and repeat based on that initial time. >> >> Is this the proper behaviour? Personally, I like the cron style >> better - it gives me tighter control, which might be required for >> better resource utilization. If I want it to start running >> immediatley, I can put in first_run Time.now. >> >> Thoughts? >> >> Cheers, >> Brett >> _______________________________________________ >> Backgroundrb-devel mailing list >> Backgroundrb-devel at rubyforge.org >> http://rubyforge.org/mailman/listinfo/backgroundrb-devel >> >> >> >> -- >> Michael Siebert >> >> www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel From ezmobius at gmail.com Mon Aug 7 11:17:32 2006 From: ezmobius at gmail.com (Ezra Zygmuntowicz) Date: Mon, 7 Aug 2006 08:17:32 -0700 Subject: [Backgroundrb-devel] Process status... In-Reply-To: References: <32b567370608070148m1f4b6977j6399fcc9b1e897d4@mail.gmail.com> Message-ID: I have a small stats add on that I will try to get out for everyone to use. I think it would be nice to be able to get the stats within rails for display so I will add it to the MiddelMan. Cheers- -Ezra On Aug 7, 2006, at 3:07 AM, Brett Walker wrote: > Totally agree. It would be great to see the status of all the jobs. > The simple solution is all I needed right now, but I can see building > out a more detailed status screen, and would need this level of > function. Also being able to set up an email notify if a critical > process drops for some reason. > > Cheers, > Brett > > On 8/7/06, Michael Siebert wrote: >> nice. but there could be another way, involving more code, but >> then it >> should be even possible to determine what workers are loaded, who is >> currently working, and other status stuff. and it would be >> platform-independent. as i could need that in some time too, i'll >> check if >> that works what i have in my mind... (if i can find some time on the >> road...) >> >> >> 2006/8/7, Brett Walker : >>> >> I've used Railscron in a couple instances, and I liked that fact that >> it has a rake task for checking the status of the process. Many >> times >> I use it in the admin interface to allow me to double check that >> everything is up and running. >> >> I couldn't find one for backgroundrb, so here is a simple one. >> Probably obvious to everyone, and no doubt there is a better way >> to do >> it: >> >> namespace :backgroundrb do >> desc "Status of BackgrounDRb" >> task :status do >> puts `ps x | grep backgroundrb | grep -v backgroundrb:status | >> grep -v grep` >> end >> end >> >> If there is another way I don't know about, please let me know. >> >> Cheers, >> Brett >> _______________________________________________ >> Backgroundrb-devel mailing list >> Backgroundrb-devel at rubyforge.org >> http://rubyforge.org/mailman/listinfo/backgroundrb-devel >> >> >> >> -- >> Michael Siebert >> >> www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel > From info at siebert-wd.de Mon Aug 7 11:26:16 2006 From: info at siebert-wd.de (Michael Siebert) Date: Mon, 7 Aug 2006 17:26:16 +0200 Subject: [Backgroundrb-devel] uninitialized constants in worker class In-Reply-To: <9E2A3DE383A4D94B9C7AAC5F1763B82F3B7E16@CBKA0018.intern.combots.com> References: <9E2A3DE383A4D94B9C7AAC5F1763B82F3B7E16@CBKA0018.intern.combots.com> Message-ID: <32b567370608070826w153c8634p5245fb6492434ca9@mail.gmail.com> Welcome Marc! this error is because load_rails does in fact NOT load rails, but your AR models. to load Rails, just include your (is it boot.rb or environment.rb?). for that, see the environment rake task, that does nothing else. you'll notice that AR logging now goes into your (development|production|test).log 2006/8/7, Marc Beyerlin : > > I am new to this list and relatively new to the backgroundrb plugin,. So > first i will say hello to everybody here, especially to Ezra > Zygmuntowicz! > > I played a little bit with a dummy worker and so far everything worked > well. > But now i want to do real work in a worker but now i get that error[1]. > It looks like that the constants configured in environment* configs are > not available to the worker class. My configuration looks like that[2]. > > Maybe someone can give me a hint to solve this problem. > > Greetz, > Marc Beyerlin > > > > [1] backgroundrb.log: > uninitialized constant SYSTEM_AMS_AVAILABLE - (NameError) > ./script/backgroundrb/../../config/../vendor/rails/activerecord/lib/../. > ./activesupport/lib/active_support/dependencies.rb:123:in > `const_missing' > ./script/backgroundrb/../../config/../components/ams_import.rb:56:in > `get_published_ams_ids' > ./script/backgroundrb/../../config/../lib/workers/warehouse.rb:8:in > `do_work' > ./script/backgroundrb/../../config/../vendor/plugins/backgroundrb/backgr > oundrb.rb:45:in `start_process' > ./script/backgroundrb/../../config/../vendor/plugins/backgroundrb/backgr > oundrb.rb:41:in `start_process' > ./script/backgroundrb/../../config/../vendor/plugins/backgroundrb/backgr > oundrb.rb:112:in `new_worker' > C:/Programme/ruby/lib/ruby/1.8/thread.rb:135:in `synchronize' > ./script/backgroundrb/../../config/../vendor/plugins/backgroundrb/backgr > oundrb.rb:104:in `new_worker' > C:/Programme/ruby/lib/ruby/1.8/drb/drb.rb:1552:in > `perform_without_block' > C:/Programme/ruby/lib/ruby/1.8/drb/drb.rb:1512:in `perform' > C:/Programme/ruby/lib/ruby/1.8/drb/drb.rb:1586:in `main_loop' > C:/Programme/ruby/lib/ruby/1.8/drb/drb.rb:1582:in `main_loop' > C:/Programme/ruby/lib/ruby/1.8/drb/drb.rb:1578:in `main_loop' > C:/Programme/ruby/lib/ruby/1.8/drb/drb.rb:1427:in `run' > C:/Programme/ruby/lib/ruby/1.8/drb/drb.rb:1424:in `run' > C:/Programme/ruby/lib/ruby/1.8/drb/drb.rb:1344:in `initialize' > C:/Programme/ruby/lib/ruby/1.8/drb/drb.rb:1624:in `start_service' > script/backgroundrb/start:84 > > > [2] background.yml > port: "22222" > timer_sleep: 60 > load_rails: true > environment: development > host: localhost > database_yml: config/database.yml > acl: > deny: all > allow: localhost 127.0.0.1 > order: deny,allow > > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel > -- Michael Siebert www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060807/effaeb1d/attachment.html From ezmobius at gmail.com Mon Aug 7 11:28:41 2006 From: ezmobius at gmail.com (Ezra Zygmuntowicz) Date: Mon, 7 Aug 2006 08:28:41 -0700 Subject: [Backgroundrb-devel] Call for examples Message-ID: <260F382D-3CCA-4CE2-8484-D1ED44B010E9@gmail.com> He folks- First off thanks to everyone for helping to make this plugin work better for all of us. Its nice to have a bunch of people testing and adding features. I would like to ask for people to post some examples workers. I would really like to get a few more workers to distribute with the plugin. Especially ones that a lot of people seem to need like Email workers. So if you are allowed to do so , would some people please post some example workers and a few little instructions on how to use them here on the list? Please use [EXAMPLE] in the subject line. This will help out I think. We can tell people to search the list archives for [EXAMPLE] subject lines to get examples. Or do people think I should put up a wiki and let people put their workers and tutorials there? I would just like to have some real world examples for folk just getting started with the plugin. And the workers I have are very insurance company specific so I don't think they are examples that anyone else would gain much by looking at. What does everyone think? I want to spend more time working on the plugin so it would be great help if a few people would step up and make some sample workers. Maybe even a little tutorial on how to make an email queue worker would be cool. Thanks Everyone- -Ezra From ezmobius at gmail.com Mon Aug 7 11:29:24 2006 From: ezmobius at gmail.com (Ezra Zygmuntowicz) Date: Mon, 7 Aug 2006 08:29:24 -0700 Subject: [Backgroundrb-devel] Debugging a worker? In-Reply-To: References: <2AD9CBA2-A8F8-4E8A-9066-D9656E0FFC19@brainspl.at> Message-ID: Yeah breakpoint will be in the next release. -Ezra On Aug 7, 2006, at 12:43 AM, Brett Walker wrote: > Ezra, this helped me. Thanks. > > You mentioned once that you were going to put in support for > breakpoint. Is that still on the table? > > Cheers, > Brett > > On 8/7/06, Ezra Zygmuntowicz wrote: >> >> >> >> On Aug 6, 2006, at 1:42 PM, Ben Johnson wrote: >> >> If there is an exception raised in my worker I rescue it and throw >> it into >> the log. This is decent, but it would really help to find out more >> information. Like the line number, the stack trace, etc. Is this >> possible? >> >> Thanks for your help. >> >> Thank You, >> Ben Johnson >> E: bjohnson at contuitive.com >> >> >> Hey Ben- >> >> If I understand what you want I think you can use the same thing >> I use to >> rescue and print the stack trace to the log file. Like this in >> your worker >> wherever you do a recuse: >> >> begin >> #something that might raise >> rescue Exception => e >> @logger.error "#{ e.message } - (#{ e.class })" << "\n" << >> (e.backtrace or []).join("\n") >> end >> >> Does that help or am I misunderstanding? >> >> Cheers- >> -Ezra >> _______________________________________________ >> Backgroundrb-devel mailing list >> Backgroundrb-devel at rubyforge.org >> http://rubyforge.org/mailman/listinfo/backgroundrb-devel >> >> > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel > From info at siebert-wd.de Mon Aug 7 11:33:35 2006 From: info at siebert-wd.de (Michael Siebert) Date: Mon, 7 Aug 2006 17:33:35 +0200 Subject: [Backgroundrb-devel] Call for examples In-Reply-To: <260F382D-3CCA-4CE2-8484-D1ED44B010E9@gmail.com> References: <260F382D-3CCA-4CE2-8484-D1ED44B010E9@gmail.com> Message-ID: <32b567370608070833q42bddad1n2cc85fd3007d48a9@mail.gmail.com> Great idea! unfortunately i don't have any workers that anyone else would need. IMO the list is completely enough. if there were forums, wikis and other stuff, there would be too much websites to check (at least for me) 2006/8/7, Ezra Zygmuntowicz : > > He folks- > > First off thanks to everyone for helping to make this plugin work > better for all of us. Its nice to have a bunch of people testing and > adding features. I would like to ask for people to post some examples > workers. I would really like to get a few more workers to distribute > with the plugin. Especially ones that a lot of people seem to need > like Email workers. So if you are allowed to do so , would some > people please post some example workers and a few little instructions > on how to use them here on the list? Please use [EXAMPLE] in the > subject line. > > This will help out I think. We can tell people to search the list > archives for [EXAMPLE] subject lines to get examples. Or do people > think I should put up a wiki and let people put their workers and > tutorials there? I would just like to have some real world examples > for folk just getting started with the plugin. And the workers I have > are very insurance company specific so I don't think they are > examples that anyone else would gain much by looking at. > > What does everyone think? I want to spend more time working on the > plugin so it would be great help if a few people would step up and > make some sample workers. Maybe even a little tutorial on how to make > an email queue worker would be cool. > > > Thanks Everyone- > > -Ezra > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel > -- Michael Siebert www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060807/d99f8a12/attachment-0001.html From info at siebert-wd.de Mon Aug 7 11:34:57 2006 From: info at siebert-wd.de (Michael Siebert) Date: Mon, 7 Aug 2006 17:34:57 +0200 Subject: [Backgroundrb-devel] Autostarting and job keys... In-Reply-To: References: Message-ID: <32b567370608070834v4a170fb5x2dc64409842e208@mail.gmail.com> seems reasonable. would you like to make a patch and send it? 2006/8/7, Brett Walker : > > I think I've got it figured out. Turns out I was mucking with the > plugin's start.rake instead of the one in scripts/backgroundrb. My > idea seems to work. > > In the 2 places where this line exits > > DRb.start_service("druby://#{CONFIG['host']}:#{CONFIG['port']}", > BackgrounDRb::MiddleMan.new(CONFIG['timer_sleep'] || 60)) > > replace with > > middle_man = BackgrounDRb::MiddleMan.new(CONFIG['timer_sleep'] || > 60) > DRb.start_service("druby://#{CONFIG['host']}:#{CONFIG['port']}", > middle_man) > > This keeps the middle man that was created and attached to the DRb > service. Now we pass that into Auto.start > > Auto.start(middle_man) > > and use it to autostart the jobs > > def self.start(middle_man) > ....... > middle_man.new_worker(:class => entry['class'], > :args => entry['args'], > :job_key => key) > > This gives me access to the jobs via the MiddleMan in my application. > > Does this seem safe and a valid fix? > > Cheers, > Brett > > On 8/7/06, Brett Walker wrote: > > I've now got 5 processes auto started. But I when I query the > > MiddleMan for their keys (in script/console), it doesn't find them. > > Looking at the start script, it looks like it might be creating a new > > MiddleMan object for each autostart > > > > BackgrounDRb::MiddleMan.new.new_worker(:class => entry['class'], > > > > Even changing it to > > > > BackgrounDRb::MiddleMan.new_worker(:class => entry['class'], > > > > didn't seem to take care of it. I even tried to create a single > > MiddleMan and pass that to autostart, still to no avail. > > > > Is there a way to have the autostarted jobs be manages by the main > > MiddleMan object? > > > > Cheers, > > Brett > > > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel > -- Michael Siebert www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060807/4b00d2e9/attachment.html From funkaster at gmail.com Mon Aug 7 11:36:22 2006 From: funkaster at gmail.com (Rolando Abarca) Date: Mon, 7 Aug 2006 11:36:22 -0400 Subject: [Backgroundrb-devel] problems with ActionMailer In-Reply-To: <3a2de0cd0608070816u104215f8y6f8789084c4e67cf@mail.gmail.com> References: <5fccb9940608062118idcd8a3dwbaed51bf1ad376b9@mail.gmail.com> <3a2de0cd0608062134t3c375252j410ef6396aeef202@mail.gmail.com> <3a2de0cd0608070428p1d8035c4xe2d6ace9b9ef63d1@mail.gmail.com> <5fccb9940608070811g204c2efcu4e27aa9c66dc1dc9@mail.gmail.com> <3a2de0cd0608070816u104215f8y6f8789084c4e67cf@mail.gmail.com> Message-ID: <5fccb9940608070836k4a90a67bnffaf19a41fcca36@mail.gmail.com> On 8/7/06, Charles Brian Quinn wrote: > what about changing template_root -- it's an actionmailer > configuration variable. yes... that's the first thing I tried. Didn't work either... :-( -- rolando -- [[ knowledge is empty, fill it ]] -- "Tam pro papa quam pro rege bibunt omnes sine lege." From info at siebert-wd.de Mon Aug 7 11:41:49 2006 From: info at siebert-wd.de (Michael Siebert) Date: Mon, 7 Aug 2006 17:41:49 +0200 Subject: [Backgroundrb-devel] :load_rails Message-ID: <32b567370608070841w1c02a47ay3cbc6c583409d3de@mail.gmail.com> if CONFIG['load_rails'] ActiveRecord::Base.allow_concurrency = true ActiveRecord::Base.establish_connection(YAML.load(ERB.new(IO.read ("#{RAILS_ROOT}/#{CONFIG['database_yml']}")).result)[CONFIG['environment']]) end if i read the code right, this option doesnt really load rails. wouldnt it be better (for those who rely on the config vars set in environment.rb) to require(File.join(RAILS_ROOT, 'config', 'environment')) so the rails core is started up and even the ActionMailer setup is loaded DRY. and the better, sql logs go to (devel|test|production).log what does everone think about it? are there any side-effects i dont know about? -- Michael Siebert www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060807/974f2697/attachment.html From info at siebert-wd.de Mon Aug 7 11:45:35 2006 From: info at siebert-wd.de (Michael Siebert) Date: Mon, 7 Aug 2006 17:45:35 +0200 Subject: [Backgroundrb-devel] problems with ActionMailer In-Reply-To: <5fccb9940608070836k4a90a67bnffaf19a41fcca36@mail.gmail.com> References: <5fccb9940608062118idcd8a3dwbaed51bf1ad376b9@mail.gmail.com> <3a2de0cd0608062134t3c375252j410ef6396aeef202@mail.gmail.com> <3a2de0cd0608070428p1d8035c4xe2d6ace9b9ef63d1@mail.gmail.com> <5fccb9940608070811g204c2efcu4e27aa9c66dc1dc9@mail.gmail.com> <3a2de0cd0608070816u104215f8y6f8789084c4e67cf@mail.gmail.com> <5fccb9940608070836k4a90a67bnffaf19a41fcca36@mail.gmail.com> Message-ID: <32b567370608070845p5b6ee060kd80996bb770147bb@mail.gmail.com> try: in your worker require File.dirname(__FILE__) + "../../../config/environment.rb" ActionMailer::Base.template_root = File.expand_path(File.dirname(__FILE__) + "../../../app/views") NotificationMailer.deliver_daily_report(users, rep, items) the first line will load environment.rb and rails, initializing your mail transport second line defines the template root, since we are in a different working dir than AM expected third line... you should see it... that works for me 2006/8/7, Rolando Abarca : > > On 8/7/06, Charles Brian Quinn wrote: > > what about changing template_root -- it's an actionmailer > > configuration variable. > > yes... that's the first thing I tried. Didn't work either... :-( > > -- > rolando -- [[ knowledge is empty, fill it ]] -- > "Tam pro papa quam pro rege bibunt omnes sine lege." > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel > -- Michael Siebert www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060807/d064d835/attachment.html From me at seebq.com Mon Aug 7 12:01:52 2006 From: me at seebq.com (Charles Brian Quinn) Date: Mon, 7 Aug 2006 12:01:52 -0400 Subject: [Backgroundrb-devel] :load_rails In-Reply-To: <32b567370608070841w1c02a47ay3cbc6c583409d3de@mail.gmail.com> References: <32b567370608070841w1c02a47ay3cbc6c583409d3de@mail.gmail.com> Message-ID: <3a2de0cd0608070901r1954984csbb9f17ef26ff1830@mail.gmail.com> The only side-effect is that now your backgroundrb process takes up about the same amount of memory as a rails instance -- could be 25-30 MB depending on what all you got in there. I personally do this too - editing the start script to load rails this way, as well: # load EVERYTHING if CONFIG['load_rails'] require "#{RAILS_ROOT}/config/environment" end Here's how I'd do it -- load_rails = true loads rails load_active_record = true loads just activerecord the default is to load all of rails now .... though. patch here: Index: script/backgroundrb/start =================================================================== --- script/backgroundrb/start (revision 37) +++ script/backgroundrb/start (working copy) @@ -62,10 +62,14 @@ rescue CONFIG = defaults end -if CONFIG['load_rails'] +if CONFIG['load_active_record'] ActiveRecord::Base.allow_concurrency = true ActiveRecord::Base.establish_connection(YAML.load(ERB.new(IO.read("#{RAILS_ROOT}/#{CONFIG['database_yml']}")).result)[CONFIG['environment']]) end +if CONFIG['load_rails'] + require "#{RAILS_ROOT}/config/environment" +end + # Require all worker classes in lib/workers/ Dir["#{RAILS_ROOT}/lib/workers/*.rb"].each{ |worker| require worker } this might save some headache on the list, and for those who care about memory, they can drop it down to just load AR and the models they need. cheers.... On 8/7/06, Michael Siebert wrote: > if CONFIG['load_rails'] > ActiveRecord::Base.allow_concurrency = true > > ActiveRecord::Base.establish_connection(YAML.load(ERB.new(IO.read("#{RAILS_ROOT}/#{CONFIG['database_yml']}")).result)[CONFIG['environment']]) > end > > if i read the code right, this option doesnt really load rails. wouldnt it > be better (for those who rely on the config vars set in environment.rb) to > require(File.join(RAILS_ROOT, 'config', 'environment')) > so the rails core is started up and even the ActionMailer setup is loaded > DRY. and the better, sql logs go to (devel|test|production).log > > what does everone think about it? are there any side-effects i dont know > about? > > -- > Michael Siebert > > www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium > _______________________________________________ > 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 From funkaster at gmail.com Mon Aug 7 12:03:43 2006 From: funkaster at gmail.com (Rolando Abarca) Date: Mon, 7 Aug 2006 12:03:43 -0400 Subject: [Backgroundrb-devel] problems with ActionMailer In-Reply-To: <32b567370608070845p5b6ee060kd80996bb770147bb@mail.gmail.com> References: <5fccb9940608062118idcd8a3dwbaed51bf1ad376b9@mail.gmail.com> <3a2de0cd0608062134t3c375252j410ef6396aeef202@mail.gmail.com> <3a2de0cd0608070428p1d8035c4xe2d6ace9b9ef63d1@mail.gmail.com> <5fccb9940608070811g204c2efcu4e27aa9c66dc1dc9@mail.gmail.com> <3a2de0cd0608070816u104215f8y6f8789084c4e67cf@mail.gmail.com> <5fccb9940608070836k4a90a67bnffaf19a41fcca36@mail.gmail.com> <32b567370608070845p5b6ee060kd80996bb770147bb@mail.gmail.com> Message-ID: <5fccb9940608070903h4c6de2eey648bf27000e21aeb@mail.gmail.com> On 8/7/06, Michael Siebert wrote: > try: > in your worker > require File.dirname(__FILE__) + > "../../../config/environment.rb" > ActionMailer::Base.template_root = > File.expand_path(File.dirname(__FILE__) + "../../../app/views") > NotificationMailer.deliver_daily_report(users, rep, > items) thanks!! that worked... although not exactly like that, this worked: require File.dirname(__FILE__) + "/../../config/environment.rb" ActionMailer::Base.template_root = File.expand_path(File.dirname(__FILE__) + "/../../app/views") Had to add a slash before and only go back two directories... -- rolando -- [[ knowledge is empty, fill it ]] -- "Tam pro papa quam pro rege bibunt omnes sine lege." From info at siebert-wd.de Mon Aug 7 12:10:19 2006 From: info at siebert-wd.de (Michael Siebert) Date: Mon, 7 Aug 2006 18:10:19 +0200 Subject: [Backgroundrb-devel] problems with ActionMailer In-Reply-To: <5fccb9940608070903h4c6de2eey648bf27000e21aeb@mail.gmail.com> References: <5fccb9940608062118idcd8a3dwbaed51bf1ad376b9@mail.gmail.com> <3a2de0cd0608062134t3c375252j410ef6396aeef202@mail.gmail.com> <3a2de0cd0608070428p1d8035c4xe2d6ace9b9ef63d1@mail.gmail.com> <5fccb9940608070811g204c2efcu4e27aa9c66dc1dc9@mail.gmail.com> <3a2de0cd0608070816u104215f8y6f8789084c4e67cf@mail.gmail.com> <5fccb9940608070836k4a90a67bnffaf19a41fcca36@mail.gmail.com> <32b567370608070845p5b6ee060kd80996bb770147bb@mail.gmail.com> <5fccb9940608070903h4c6de2eey648bf27000e21aeb@mail.gmail.com> Message-ID: <32b567370608070910m6b7831cam76b30abd802dcf48@mail.gmail.com> hrm... exactly the code i posted works for me... huh? 2006/8/7, Rolando Abarca : > > On 8/7/06, Michael Siebert wrote: > > try: > > in your worker > > require File.dirname(__FILE__) + > > "../../../config/environment.rb" > > ActionMailer::Base.template_root = > > File.expand_path(File.dirname(__FILE__) + "../../../app/views") > > NotificationMailer.deliver_daily_report(users, rep, > > items) > > thanks!! that worked... although not exactly like that, this worked: > > require File.dirname(__FILE__) + "/../../config/environment.rb" > ActionMailer::Base.template_root = > File.expand_path(File.dirname(__FILE__) + "/../../app/views") > > Had to add a slash before and only go back two directories... > -- > rolando -- [[ knowledge is empty, fill it ]] -- > "Tam pro papa quam pro rege bibunt omnes sine lege." > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel > -- Michael Siebert www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060807/ed59dc24/attachment-0001.html From info at siebert-wd.de Mon Aug 7 12:13:52 2006 From: info at siebert-wd.de (Michael Siebert) Date: Mon, 7 Aug 2006 18:13:52 +0200 Subject: [Backgroundrb-devel] reply-to email header Message-ID: <32b567370608070913s624a898gdcbb948f5a88e21e@mail.gmail.com> why does the mail server not set the reply-to header? gmail ignores the list-* stuff and when i click reply it replies to whoever wrote the mail... that ... (dontwannasaythatword) is it a rubyforge thing or where do i have to complain? greets -- Michael Siebert www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060807/10de30dd/attachment.html From ezmobius at gmail.com Mon Aug 7 13:29:57 2006 From: ezmobius at gmail.com (Ezra Zygmuntowicz) Date: Mon, 7 Aug 2006 10:29:57 -0700 Subject: [Backgroundrb-devel] uninitialized constants in worker class In-Reply-To: <32b567370608070826w153c8634p5245fb6492434ca9@mail.gmail.com> References: <9E2A3DE383A4D94B9C7AAC5F1763B82F3B7E16@CBKA0018.intern.combots.com> <32b567370608070826w153c8634p5245fb6492434ca9@mail.gmail.com> Message-ID: <9D4B234D-13A2-4436-B88E-4999F7A31AD5@gmail.com> Yeah Michael is correct. Thats something I really need to fix. The next release will have a load_activerecord option that will do the same as the current load_rails and the load_rails will actually load all of rails. Its definitely inconsistent the way it is now. -Ezra On Aug 7, 2006, at 8:26 AM, Michael Siebert wrote: > Welcome Marc! > > this error is because load_rails does in fact NOT load rails, but > your AR models. to load Rails, just include your (is it boot.rb or > environment.rb?). for that, see the environment rake task, that > does nothing else. you'll notice that AR logging now goes into your > (development|production|test).log > > > 2006/8/7, Marc Beyerlin : > I am new to this list and relatively new to the backgroundrb > plugin,. So > first i will say hello to everybody here, especially to Ezra > Zygmuntowicz! > > I played a little bit with a dummy worker and so far everything worked > well. > But now i want to do real work in a worker but now i get that error > [1]. > It looks like that the constants configured in environment* configs > are > not available to the worker class. My configuration looks like that > [2]. > > Maybe someone can give me a hint to solve this problem. > > Greetz, > Marc Beyerlin > > > > [1] backgroundrb.log: > uninitialized constant SYSTEM_AMS_AVAILABLE - (NameError) > ./script/backgroundrb/../../config/../vendor/rails/activerecord/ > lib/../. > ./activesupport/lib/active_support/dependencies.rb:123:in > `const_missing' > ./script/backgroundrb/../../config/../components/ams_import.rb:56:in > `get_published_ams_ids' > ./script/backgroundrb/../../config/../lib/workers/warehouse.rb:8:in > `do_work' > ./script/backgroundrb/../../config/../vendor/plugins/backgroundrb/ > backgr > oundrb.rb:45:in `start_process' > ./script/backgroundrb/../../config/../vendor/plugins/backgroundrb/ > backgr > oundrb.rb:41:in `start_process' > ./script/backgroundrb/../../config/../vendor/plugins/backgroundrb/ > backgr > oundrb.rb:112:in `new_worker' > C:/Programme/ruby/lib/ruby/1.8/thread.rb:135:in `synchronize' > ./script/backgroundrb/../../config/../vendor/plugins/backgroundrb/ > backgr > oundrb.rb:104:in `new_worker' > C:/Programme/ruby/lib/ruby/1.8/drb/drb.rb:1552:in > `perform_without_block' > C:/Programme/ruby/lib/ruby/1.8/drb/drb.rb:1512:in `perform' > C:/Programme/ruby/lib/ruby/1.8/drb/drb.rb:1586:in `main_loop' > C:/Programme/ruby/lib/ruby/1.8/drb/drb.rb:1582:in `main_loop' > C:/Programme/ruby/lib/ruby/1.8/drb/drb.rb:1578:in `main_loop' > C:/Programme/ruby/lib/ruby/1.8/drb/drb.rb:1427:in `run' > C:/Programme/ruby/lib/ruby/1.8/drb/drb.rb:1424:in `run' > C:/Programme/ruby/lib/ruby/1.8/drb/drb.rb:1344:in `initialize' > C:/Programme/ruby/lib/ruby/1.8/drb/drb.rb:1624:in `start_service' > script/backgroundrb/start:84 > > > [2] background.yml > port: "22222" > timer_sleep: 60 > load_rails: true > environment: development > host: localhost > database_yml: config/database.yml > acl: > deny: all > allow: localhost 127.0.0.1 > order: deny,allow > > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel > > > > -- > Michael Siebert > > www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060807/73218d87/attachment.html From joel at luckyoliver.com Mon Aug 7 18:51:28 2006 From: joel at luckyoliver.com (Joel Hayhurst) Date: Mon, 7 Aug 2006 15:51:28 -0700 Subject: [Backgroundrb-devel] Memory leak? Message-ID: I am using BackgrounDRb to resize images after they are accepted into our system. However, it has become clear that this creates a memory leak. I'm not sure exactly where the leak exists, but I don't think it's in my own code as it is presently being used in production and has resized thousands of images without a leak occurring, thanks to calling GC.start after every RMagick image read. I have it working like this. First of all, I changed the start script to include environment.rb and therefore the ENTIRE Rails environment, because my Image model is an engine plugin. Then, I have it perform this upon acceptance: MiddleMan.new_worker :class => :resize_worker, :args => self.id And here are the contents of ResizeWorker: class ResizeWorker < BackgrounDRb::Rails def do_work(args) image = Image.find(args) image.resize_all terminate end end If I run this on a few dozen images simultaneously I watch as top starts slowly requiring more memory for backgroundrb. Dropping into script/console tells me two things. For one, MiddleMan.jobs still has every job, despite my terminate() call. Second, calling destroy_worker on any of these calls, or gc! (Time.now), does not free up any of the memory, even though the jobs disappear. GC.start also does not free up any memory. If you have any advice on this, that would be great. Thanks, Joel From ezmobius at gmail.com Mon Aug 7 19:11:05 2006 From: ezmobius at gmail.com (Ezra Zygmuntowicz) Date: Mon, 7 Aug 2006 16:11:05 -0700 Subject: [Backgroundrb-devel] Memory leak? In-Reply-To: References: Message-ID: <374F0F55-67E2-4D83-89D1-D30D8BED1F5B@brainspl.at> On Aug 7, 2006, at 3:51 PM, Joel Hayhurst wrote: > I am using BackgrounDRb to resize images after they are accepted into > our system. However, it has become clear that this creates a memory > leak. I'm not sure exactly where the leak exists, but I don't think > it's in my own code as it is presently being used in production and > has resized thousands of images without a leak occurring, thanks to > calling GC.start after every RMagick image read. > > I have it working like this. First of all, I changed the start > script to include environment.rb and therefore the ENTIRE Rails > environment, because my Image model is an engine plugin. Then, I > have it perform this upon acceptance: > > MiddleMan.new_worker :class => :resize_worker, :args => > self.id > > And here are the contents of ResizeWorker: > > class ResizeWorker < BackgrounDRb::Rails > def do_work(args) > image = Image.find(args) > image.resize_all > terminate > end > end > > If I run this on a few dozen images simultaneously I watch as top > starts slowly requiring more memory for backgroundrb. Dropping into > script/console tells me two things. > > For one, MiddleMan.jobs still has every job, despite my terminate() > call. Second, calling destroy_worker on any of these calls, or gc! > (Time.now), does not free up any of the memory, even though the jobs > disappear. GC.start also does not free up any memory. > > If you have any advice on this, that would be great. > > Thanks, > Joel Hey Joel- Calling terminate does not immediately terminate the worker class. All it does is flag the thread as ok to terminate when a delete_worker call is made. So you will still need to call delete_worker or gc! in order to clear your worker out of @jobs. As far as actually getting the process memory back, you need to realize that even if you call GC.start, that doesn't mean that ruby will automatically clean up all garbage. What platform are you on? And can you confirm whether the real memory or the virtual memory decrease after a delete_worker and a GC.start ? Where did you call GC.start from in your experiment? If you called it from the command line then it will not effect the drb server. Try this, add GC.start to the gc! method in the backgroundrb.rb file in the plugin root and restarting your drb server. like this: def gc!(age) @timestamps.each do |job_key, timestamp| if timestamp[timestamp[:expire_type]] < age delete_worker(job_key) end end GC.start end And now run a bunch of workers until memory usage grows. Then run MiddleMan.gc! Time.now from script/console and wait a little bit to see if your memory usage goes down. Please report back if this does solve your problem and I will add it to the distro. Also RMagick is know to leak sometimes so I have been using MiniMagick myself when I have needed to do image resizing in a worker. Let me know if none of these things solve your issue and I will try to get to the bottom of this. THanks -Ezra From ezmobius at gmail.com Mon Aug 7 19:40:28 2006 From: ezmobius at gmail.com (Ezra Zygmuntowicz) Date: Mon, 7 Aug 2006 16:40:28 -0700 Subject: [Backgroundrb-devel] Memory leak? In-Reply-To: References: <374F0F55-67E2-4D83-89D1-D30D8BED1F5B@brainspl.at> Message-ID: Joel- OK I think that is the behavior we are looking for. With the GC.start in the gc! method I think you will be ok. I will add an option to completely terminate a worker and call GC.start from within a worker when it is done with its job. It will be in the next release. I will experiment with RMagick and drb myself here to see if I can get it to behave correctly. But MiniMagick works great sine it shells out to the Magick command line tools and therefore doesn't ever leak any memory. You may want to try that if you are memory constrained at all. Sometimes when a process on linux eats up a lot of memory and tries to free it, it will not go away immediately in top. You said the virtual memory went down , what about the real memory? Where is that at after the GC.start call? -Ezra On Aug 7, 2006, at 4:27 PM, Joel Hayhurst wrote: > I'm not sure how to make it call delete_worker or gc! reliably; I'd > rather just have the worker die completely when the do_work method > was finished. Alternatively, a nice way to queue up calls to one > worker would do just as well, but I found that making a singleton > and later getting it and calling do_work(newarg) made me wait until > do_work was completed in the request. > > Anyway -- RMagick does have a "leak" of sorts in that you must call > GC.start after every Image.read() call. However after doing this I > have had no leak issues, and my resize_all method in the Image > class merely calls my resize method multiple times for all of the > sizes I need; there are no missing GC.start calls there. I would > be willing to try MiniMagick. > > I added your suggestion, restarted backgroundrb and mongrel, and am > presently having it resize a bunch of images. It started at around > ~20 megs virtual memory and after resizing about 100 images it is > at ~229 megs. Real memory usage is just about as high, and it is > using up 11.1% of my available RAM. The platform is Gentoo Linux. > Doing multiple hundreds of images I have seen it get up to around > 800 megs before I stopped. > > OK, I just ran gc!(Time.now) with the new GC.start call, and it > immediately went down to 143 megs of virtual memory. That is > unexpected; I expected it to either stay the same or drop down > nearer to 20 megs. > > On Aug 7, 2006, at 4:11 PM, Ezra Zygmuntowicz wrote: > >> >> On Aug 7, 2006, at 3:51 PM, Joel Hayhurst wrote: >> >>> I am using BackgrounDRb to resize images after they are accepted >>> into >>> our system. However, it has become clear that this creates a memory >>> leak. I'm not sure exactly where the leak exists, but I don't think >>> it's in my own code as it is presently being used in production and >>> has resized thousands of images without a leak occurring, thanks to >>> calling GC.start after every RMagick image read. >>> >>> I have it working like this. First of all, I changed the start >>> script to include environment.rb and therefore the ENTIRE Rails >>> environment, because my Image model is an engine plugin. Then, I >>> have it perform this upon acceptance: >>> >>> MiddleMan.new_worker :class => :resize_worker, :args => >>> self.id >>> >>> And here are the contents of ResizeWorker: >>> >>> class ResizeWorker < BackgrounDRb::Rails >>> def do_work(args) >>> image = Image.find(args) >>> image.resize_all >>> terminate >>> end >>> end >>> >>> If I run this on a few dozen images simultaneously I watch as top >>> starts slowly requiring more memory for backgroundrb. Dropping into >>> script/console tells me two things. >>> >>> For one, MiddleMan.jobs still has every job, despite my terminate() >>> call. Second, calling destroy_worker on any of these calls, or gc! >>> (Time.now), does not free up any of the memory, even though the jobs >>> disappear. GC.start also does not free up any memory. >>> >>> If you have any advice on this, that would be great. >>> >>> Thanks, >>> Joel >> >> >> Hey Joel- >> >> Calling terminate does not immediately terminate the worker >> class. All it does is flag the thread as ok to terminate when a >> delete_worker call is made. So you will still need to call >> delete_worker or gc! in order to clear your worker out of @jobs. >> As far as actually getting the process memory back, you need to >> realize that even if you call GC.start, that doesn't mean that >> ruby will automatically clean up all garbage. What platform are >> you on? And can you confirm whether the real memory or the virtual >> memory decrease after a delete_worker and a GC.start ? >> >> Where did you call GC.start from in your experiment? If you >> called it from the command line then it will not effect the drb >> server. Try this, add GC.start to the gc! method in the >> backgroundrb.rb file in the plugin root and restarting your drb >> server. like this: >> >> def gc!(age) >> @timestamps.each do |job_key, timestamp| >> if timestamp[timestamp[:expire_type]] < age >> delete_worker(job_key) >> end >> end >> GC.start >> end >> >> And now run a bunch of workers until memory usage grows. Then run >> MiddleMan.gc! Time.now from script/console and wait a little bit >> to see if your memory usage goes down. Please report back if this >> does solve your problem and I will add it to the distro. >> >> Also RMagick is know to leak sometimes so I have been using >> MiniMagick myself when I have needed to do image resizing in a >> worker. >> >> Let me know if none of these things solve your issue and I will >> try to get to the bottom of this. >> >> THanks >> -Ezra >> >> >> >> >> > From tsailipu at gmail.com Mon Aug 7 22:10:37 2006 From: tsailipu at gmail.com (Philip Lipu Tsai) Date: Mon, 7 Aug 2006 19:10:37 -0700 Subject: [Backgroundrb-devel] "include DRbUndumped" error Message-ID: Hi, I am getting my hands on trying the cool BackgrounDrb plugin. Following various discussions and suggestsion, I included "include DRbUndumped" in my ActiveRecord model. However, the following exception occurs after I tried this and hit the page that uses this model. Does anyone know why this is so? Is it possible that an object cannot be DRbUndumped (that would mean, we can't ever pass a reference to such object across DRb for BackgrounDrb to process)? Thanks! Philip TypeError (can't dump): /usr/lib/ruby/1.8/drb/drb.rb:395:in `_dump' /usr/lib/ruby/1.8/pstore.rb:348:in `dump' /usr/lib/ruby/1.8/pstore.rb:326:in `transaction' /usr/lib/ruby/1.8/cgi/session/pstore.rb:90:in `update' /usr/lib/ruby/1.8/cgi/session/pstore.rb:97:in `close' /usr/lib/ruby/1.8/cgi/session.rb:330:in `close' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/base.rb: 984:in `close_session' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/base.rb: 1026:in `process_cleanup_without_flash' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/flash.rb :147:in `process_cleanup_without_filters' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/filters. rb:439:in `process_cleanup_without_session_management_support' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/session_ management.rb:126:in `process_cleanup_without_components' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/componen ts.rb:182:in `process_cleanup' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/base.rb: 385:in `process_without_filters' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/filters. rb:377:in `process_without_session_management_support' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/session_ management.rb:117:in `process' /usr/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/dispatcher.rb:38:in `dispatch' /usr/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/webrick_server.rb:115:in `handle _dispatch' /usr/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/webrick_server.rb:81:in `service ' /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service' /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run' /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread' /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread' /usr/lib/ruby/1.8/webrick/server.rb:95:in `start' /usr/lib/ruby/1.8/webrick/server.rb:92:in `start' /usr/lib/ruby/1.8/webrick/server.rb:23:in `start' /usr/lib/ruby/1.8/webrick/server.rb:82:in `start' /usr/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/webrick_server.rb:67:in `dispatc h' /usr/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/commands/servers/webrick.rb:59 /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require' /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependenc ies.rb:147:in `require' /usr/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/commands/server.rb:30 /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require' /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependenc ies.rb:147:in `require' script/server:3 From gethemant at gmail.com Tue Aug 8 02:29:05 2006 From: gethemant at gmail.com (hemant) Date: Tue, 8 Aug 2006 11:59:05 +0530 Subject: [Backgroundrb-devel] Call for examples In-Reply-To: <32b567370608070833q42bddad1n2cc85fd3007d48a9@mail.gmail.com> References: <260F382D-3CCA-4CE2-8484-D1ED44B010E9@gmail.com> <32b567370608070833q42bddad1n2cc85fd3007d48a9@mail.gmail.com> Message-ID: I am using backgroundrb to read rss feeds for all the sysmbols from Yahoo finance. require 'rss/2.0' require 'open-uri' class ResearchWorker < BackgrounDRb::Rails def do_work(args) yahoo_url = "http://finance.yahoo.com/rss/headline?s=" symbol_list = NasdaqSymbols.find_all() while true symbol_list.each do|sym| temp_sym = sym.symbol.strip temp_url = yahoo_url + temp_sym @logger.debug("Searching for symbol: #{temp_url}") get_feeds(temp_url,temp_sym) end sleep(10*60) end # end of infinite loop end # end of do_worker function protected def get_feeds(url,temp_sym) open(url) do |http| response = http.read result = RSS::Parser.parse(response,false) result.items.each_with_index do |item,i| begin title = item.title[0..99] link = item.link description = item.description pub_date = item.pubDate #check if the feed is there in db feed_data = YahooFeeds.find(:first,:conditions => ["title = ?",title]) unless feed_data.nil? next end #@logger.debug("title = #{title} and link = #{link} ") if feed = YahooFeeds.create( :title => title, :link => link, :description => description, :pub_date => pub_date, :symbol => temp_sym ) @logger.debug("Saved to #{temp_sym}") else @logger.debug("Error saving #{temp_sym}") end rescue Exception => e @logger.debug("#{e.to_s}") end end end end # end of get_feeds function end On 8/7/06, Michael Siebert wrote: > > Great idea! > unfortunately i don't have any workers that anyone else would need. > IMO the list is completely enough. if there were forums, wikis and other > stuff, there would be too much websites to check (at least for me) > > 2006/8/7, Ezra Zygmuntowicz : > > > He folks- > > > > First off thanks to everyone for helping to make this plugin > > work > > better for all of us. Its nice to have a bunch of people testing and > > adding features. I would like to ask for people to post some examples > > workers. I would really like to get a few more workers to distribute > > with the plugin. Especially ones that a lot of people seem to need > > like Email workers. So if you are allowed to do so , would some > > people please post some example workers and a few little instructions > > on how to use them here on the list? Please use [EXAMPLE] in the > > subject line. > > > > This will help out I think. We can tell people to search the > > list > > archives for [EXAMPLE] subject lines to get examples. Or do people > > think I should put up a wiki and let people put their workers and > > tutorials there? I would just like to have some real world examples > > for folk just getting started with the plugin. And the workers I have > > are very insurance company specific so I don't think they are > > examples that anyone else would gain much by looking at. > > > > What does everyone think? I want to spend more time working on > > the > > plugin so it would be great help if a few people would step up and > > make some sample workers. Maybe even a little tutorial on how to make > > an email queue worker would be cool. > > > > > > Thanks Everyone- > > > > -Ezra > > _______________________________________________ > > Backgroundrb-devel mailing list > > Backgroundrb-devel at rubyforge.org > > http://rubyforge.org/mailman/listinfo/backgroundrb-devel > > > > > > -- > Michael Siebert > > www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium > > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel > > -- nothing much to talk -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060808/41f808c3/attachment.html From gethemant at gmail.com Tue Aug 8 02:39:26 2006 From: gethemant at gmail.com (hemant) Date: Tue, 8 Aug 2006 12:09:26 +0530 Subject: [Backgroundrb-devel] Memory leak? In-Reply-To: References: <374F0F55-67E2-4D83-89D1-D30D8BED1F5B@brainspl.at> Message-ID: Erza, Similar to this, I have case, where though worker thread will be invoked by user from page, but user will not interact with any further.So, this thread, will run and once its done with its job, it should quit. Now, is it possible? Without a explicit cron job, which will delete older worker threads? The job, may take any amount of time.If "terminate" doesnt delete the thread, then there should be a mechanism for self-deleting(or a method, which we can call explicitly) the thread from worker threads, once they are done with their job. On 8/8/06, Ezra Zygmuntowicz wrote: > > > Joel- > > OK I think that is the behavior we are looking for. With the > GC.start in the gc! method I think you will be ok. I will add an > option to completely terminate a worker and call GC.start from within > a worker when it is done with its job. It will be in the next > release. I will experiment with RMagick and drb myself here to see if > I can get it to behave correctly. But MiniMagick works great sine it > shells out to the Magick command line tools and therefore doesn't > ever leak any memory. You may want to try that if you are memory > constrained at all. Sometimes when a process on linux eats up a lot > of memory and tries to free it, it will not go away immediately in > top. You said the virtual memory went down , what about the real > memory? Where is that at after the GC.start call? > > -Ezra > > > On Aug 7, 2006, at 4:27 PM, Joel Hayhurst wrote: > > > I'm not sure how to make it call delete_worker or gc! reliably; I'd > > rather just have the worker die completely when the do_work method > > was finished. Alternatively, a nice way to queue up calls to one > > worker would do just as well, but I found that making a singleton > > and later getting it and calling do_work(newarg) made me wait until > > do_work was completed in the request. > > > > Anyway -- RMagick does have a "leak" of sorts in that you must call > > GC.start after every Image.read() call. However after doing this I > > have had no leak issues, and my resize_all method in the Image > > class merely calls my resize method multiple times for all of the > > sizes I need; there are no missing GC.start calls there. I would > > be willing to try MiniMagick. > > > > I added your suggestion, restarted backgroundrb and mongrel, and am > > presently having it resize a bunch of images. It started at around > > ~20 megs virtual memory and after resizing about 100 images it is > > at ~229 megs. Real memory usage is just about as high, and it is > > using up 11.1% of my available RAM. The platform is Gentoo Linux. > > Doing multiple hundreds of images I have seen it get up to around > > 800 megs before I stopped. > > > > OK, I just ran gc!(Time.now) with the new GC.start call, and it > > immediately went down to 143 megs of virtual memory. That is > > unexpected; I expected it to either stay the same or drop down > > nearer to 20 megs. > > > > On Aug 7, 2006, at 4:11 PM, Ezra Zygmuntowicz wrote: > > > >> > >> On Aug 7, 2006, at 3:51 PM, Joel Hayhurst wrote: > >> > >>> I am using BackgrounDRb to resize images after they are accepted > >>> into > >>> our system. However, it has become clear that this creates a memory > >>> leak. I'm not sure exactly where the leak exists, but I don't think > >>> it's in my own code as it is presently being used in production and > >>> has resized thousands of images without a leak occurring, thanks to > >>> calling GC.start after every RMagick image read. > >>> > >>> I have it working like this. First of all, I changed the start > >>> script to include environment.rb and therefore the ENTIRE Rails > >>> environment, because my Image model is an engine plugin. Then, I > >>> have it perform this upon acceptance: > >>> > >>> MiddleMan.new_worker :class => :resize_worker, :args => > >>> self.id > >>> > >>> And here are the contents of ResizeWorker: > >>> > >>> class ResizeWorker < BackgrounDRb::Rails > >>> def do_work(args) > >>> image = Image.find(args) > >>> image.resize_all > >>> terminate > >>> end > >>> end > >>> > >>> If I run this on a few dozen images simultaneously I watch as top > >>> starts slowly requiring more memory for backgroundrb. Dropping into > >>> script/console tells me two things. > >>> > >>> For one, MiddleMan.jobs still has every job, despite my terminate() > >>> call. Second, calling destroy_worker on any of these calls, or gc! > >>> (Time.now), does not free up any of the memory, even though the jobs > >>> disappear. GC.start also does not free up any memory. > >>> > >>> If you have any advice on this, that would be great. > >>> > >>> Thanks, > >>> Joel > >> > >> > >> Hey Joel- > >> > >> Calling terminate does not immediately terminate the worker > >> class. All it does is flag the thread as ok to terminate when a > >> delete_worker call is made. So you will still need to call > >> delete_worker or gc! in order to clear your worker out of @jobs. > >> As far as actually getting the process memory back, you need to > >> realize that even if you call GC.start, that doesn't mean that > >> ruby will automatically clean up all garbage. What platform are > >> you on? And can you confirm whether the real memory or the virtual > >> memory decrease after a delete_worker and a GC.start ? > >> > >> Where did you call GC.start from in your experiment? If you > >> called it from the command line then it will not effect the drb > >> server. Try this, add GC.start to the gc! method in the > >> backgroundrb.rb file in the plugin root and restarting your drb > >> server. like this: > >> > >> def gc!(age) > >> @timestamps.each do |job_key, timestamp| > >> if timestamp[timestamp[:expire_type]] < age > >> delete_worker(job_key) > >> end > >> end > >> GC.start > >> end > >> > >> And now run a bunch of workers until memory usage grows. Then run > >> MiddleMan.gc! Time.now from script/console and wait a little bit > >> to see if your memory usage goes down. Please report back if this > >> does solve your problem and I will add it to the distro. > >> > >> Also RMagick is know to leak sometimes so I have been using > >> MiniMagick myself when I have needed to do image resizing in a > >> worker. > >> > >> Let me know if none of these things solve your issue and I will > >> try to get to the bottom of this. > >> > >> THanks > >> -Ezra > >> > >> > >> > >> > >> > > > > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel > -- nothing much to talk -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060808/25253f19/attachment-0001.html From fernand.galiana at gmail.com Tue Aug 8 11:15:32 2006 From: fernand.galiana at gmail.com (Fernand Galiana) Date: Tue, 8 Aug 2006 09:15:32 -0600 Subject: [Backgroundrb-devel] Problem installing the plugin... Message-ID: <30ab479c0608080815n7dbab8bdxfd6836f7d87e0e4a@mail.gmail.com> Hi, I am running ruby 1.8.4 rails 1.1 on Mac OSx and I am getting the following error installing the plugin. Any ideas ? ( BTW This is a brand new rails app ) Thanks !! ruby script/plugin install svn://rubyforge.org/var/svn/backgroundrb --force subversion/libsvn_wc/lock.c:630: (apr_err=155007) svn: '/Users/fgaliana/work/samples/fred/vendor/plugins' is not a working copy /usr/local/lib/ruby/1.8/open-uri.rb:88:in `initialize': No such file or directory - svn://rubyforge.org/var/svn/backgroundrb (Errno::ENOENT) from /usr/local/lib/ruby/1.8/open-uri.rb:88:in `open' from /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/commands/plugin.rb:858:in `fetch_dir' from /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/commands/plugin.rb:852:in `fetch' from /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/commands/plugin.rb:851:in `fetch' from /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/commands/plugin.rb:218:in `install_using_http' from /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/commands/plugin.rb:168:in `install' from /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/commands/plugin.rb:733:in `parse!' from /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/commands/plugin.rb:731:in `parse!' from /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/commands/plugin.rb:446:in `parse!' from /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/commands/plugin.rb:462:in `parse!' from /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.0 /lib/commands/plugin.rb:866 from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.3.0/lib/active_support/dependencies.rb:136:in `require' from script/plugin:3 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060808/59374797/attachment.html From ezmobius at gmail.com Tue Aug 8 11:15:59 2006 From: ezmobius at gmail.com (Ezra Zygmuntowicz) Date: Tue, 8 Aug 2006 08:15:59 -0700 Subject: [Backgroundrb-devel] [ANN] New Release Message-ID: <68A01563-A08B-470B-9F31-7F3628F06FFE@gmail.com> Folks- I just pushed out a new release last night. THis is a bug fix release as well as some new features that have come up that people need. I made the MiddleMan class include Singleton so it is now a true singleton. What this means is that the autostart stuff now works correctly because you can always get the same MiddleMan instance from anywhere within the drb server including your workers. This means that if you want to, you can start new workers from within a worker like so: #in a worker class @key = spawn_worker :class => :foo, :args => 'whatever' This also means that you can now finally kill your worker completely from within itself when you are done with it. THis is for everyone who needs to fire off a worker and forget it and let it clean up after itself. To kill a worker from within itself do this: #in worker class, kill with no args kills the current worker kill # if you spawned another worker from within your worker and you have its job key you can kill it too kill(job_key) I also went in a refactored some code and added more test cases. Things are purring pretty nicely now. This release still does not address the cron worker issue. I will be working on that here soon to see what I can do to make it more cron like. Please download the new version and test your stuff with it for me. I don't think this release should affect and pre existing code you have, it just made things cleaner internally. Cheers- -Ezra From ezmobius at gmail.com Tue Aug 8 11:16:12 2006 From: ezmobius at gmail.com (Ezra Zygmuntowicz) Date: Tue, 8 Aug 2006 08:16:12 -0700 Subject: [Backgroundrb-devel] Memory leak? In-Reply-To: References: <374F0F55-67E2-4D83-89D1-D30D8BED1F5B@brainspl.at> Message-ID: Yes, please see my [ANN] thread. I just pushed a minor new release last night that solves many issues including this one. -Ezra On Aug 7, 2006, at 11:39 PM, hemant wrote: > Erza, > > Similar to this, I have case, where though worker thread will be > invoked by user from page, but user will not interact with any > further.So, this thread, will run and once its done with its job, > it should quit. > > Now, is it possible? Without a explicit cron job, which will delete > older worker threads? > > The job, may take any amount of time.If "terminate" doesnt delete > the thread, then there should be a mechanism for self-deleting(or a > method, which we can call explicitly) the thread from worker > threads, once they are done with their job. > > > On 8/8/06, Ezra Zygmuntowicz wrote: > > Joel- > > OK I think that is the behavior we are looking for. With the > GC.start in the gc! method I think you will be ok. I will add an > option to completely terminate a worker and call GC.start from within > a worker when it is done with its job. It will be in the next > release. I will experiment with RMagick and drb myself here to see if > I can get it to behave correctly. But MiniMagick works great sine it > shells out to the Magick command line tools and therefore doesn't > ever leak any memory. You may want to try that if you are memory > constrained at all. Sometimes when a process on linux eats up a lot > of memory and tries to free it, it will not go away immediately in > top. You said the virtual memory went down , what about the real > memory? Where is that at after the GC.start call? > > -Ezra > > > On Aug 7, 2006, at 4:27 PM, Joel Hayhurst wrote: > > > I'm not sure how to make it call delete_worker or gc! reliably; I'd > > rather just have the worker die completely when the do_work method > > was finished. Alternatively, a nice way to queue up calls to one > > worker would do just as well, but I found that making a singleton > > and later getting it and calling do_work(newarg) made me wait until > > do_work was completed in the request. > > > > Anyway -- RMagick does have a "leak" of sorts in that you must call > > GC.start after every Image.read() call. However after doing this I > > have had no leak issues, and my resize_all method in the Image > > class merely calls my resize method multiple times for all of the > > sizes I need; there are no missing GC.start calls there. I would > > be willing to try MiniMagick. > > > > I added your suggestion, restarted backgroundrb and mongrel, and am > > presently having it resize a bunch of images. It started at around > > ~20 megs virtual memory and after resizing about 100 images it is > > at ~229 megs. Real memory usage is just about as high, and it is > > using up 11.1% of my available RAM. The platform is Gentoo Linux. > > Doing multiple hundreds of images I have seen it get up to around > > 800 megs before I stopped. > > > > OK, I just ran gc!(Time.now ) with the new GC.start call, and it > > immediately went down to 143 megs of virtual memory. That is > > unexpected; I expected it to either stay the same or drop down > > nearer to 20 megs. > > > > On Aug 7, 2006, at 4:11 PM, Ezra Zygmuntowicz wrote: > > > >> > >> On Aug 7, 2006, at 3:51 PM, Joel Hayhurst wrote: > >> > >>> I am using BackgrounDRb to resize images after they are accepted > >>> into > >>> our system. However, it has become clear that this creates a > memory > >>> leak. I'm not sure exactly where the leak exists, but I don't > think > >>> it's in my own code as it is presently being used in production > and > >>> has resized thousands of images without a leak occurring, > thanks to > >>> calling GC.start after every RMagick image read. > >>> > >>> I have it working like this. First of all, I changed the start > >>> script to include environment.rb and therefore the ENTIRE Rails > >>> environment, because my Image model is an engine plugin. Then, I > >>> have it perform this upon acceptance: > >>> > >>> MiddleMan.new_worker :class => :resize_worker, :args => > >>> self.id > >>> > >>> And here are the contents of ResizeWorker: > >>> > >>> class ResizeWorker < BackgrounDRb::Rails > >>> def do_work(args) > >>> image = Image.find(args) > >>> image.resize_all > >>> terminate > >>> end > >>> end > >>> > >>> If I run this on a few dozen images simultaneously I watch as top > >>> starts slowly requiring more memory for backgroundrb. Dropping > into > >>> script/console tells me two things. > >>> > >>> For one, MiddleMan.jobs still has every job, despite my > terminate() > >>> call. Second, calling destroy_worker on any of these calls, or > gc! > >>> (Time.now), does not free up any of the memory, even though the > jobs > >>> disappear. GC.start also does not free up any memory. > >>> > >>> If you have any advice on this, that would be great. > >>> > >>> Thanks, > >>> Joel > >> > >> > >> Hey Joel- > >> > >> Calling terminate does not immediately terminate the worker > >> class. All it does is flag the thread as ok to terminate when a > >> delete_worker call is made. So you will still need to call > >> delete_worker or gc! in order to clear your worker out of @jobs. > >> As far as actually getting the process memory back, you need to > >> realize that even if you call GC.start, that doesn't mean that > >> ruby will automatically clean up all garbage. What platform are > >> you on? And can you confirm whether the real memory or the virtual > >> memory decrease after a delete_worker and a GC.start ? > >> > >> Where did you call GC.start from in your experiment? If you > >> called it from the command line then it will not effect the drb > >> server. Try this, add GC.start to the gc! method in the > >> backgroundrb.rb file in the plugin root and restarting your drb > >> server. like this: > >> > >> def gc!(age) > >> @timestamps.each do |job_key, timestamp| > >> if timestamp[timestamp[:expire_type]] < age > >> delete_worker(job_key) > >> end > >> end > >> GC.start > >> end > >> > >> And now run a bunch of workers until memory usage grows. > Then run > >> MiddleMan.gc! Time.now from script/console and wait a little bit > >> to see if your memory usage goes down. Please report back if this > >> does solve your problem and I will add it to the distro. > >> > >> Also RMagick is know to leak sometimes so I have been using > >> MiniMagick myself when I have needed to do image resizing in a > >> worker. > >> > >> Let me know if none of these things solve your issue and I > will > >> try to get to the bottom of this. > >> > >> THanks > >> -Ezra > >> > >> > >> > >> > >> > > > > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel > > > > -- > nothing much to talk > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060808/5f68d8d0/attachment.html From info at siebert-wd.de Tue Aug 8 11:37:12 2006 From: info at siebert-wd.de (Michael Siebert) Date: Tue, 8 Aug 2006 17:37:12 +0200 Subject: [Backgroundrb-devel] Problem installing the plugin... In-Reply-To: <30ab479c0608080815n7dbab8bdxfd6836f7d87e0e4a@mail.gmail.com> References: <30ab479c0608080815n7dbab8bdxfd6836f7d87e0e4a@mail.gmail.com> Message-ID: <32b567370608080837j2ab9a8c7q615b55ee76fddd@mail.gmail.com> Fernand, i think the script it trying to set svn:externals for bgdrb and your app isn't in svn. or something other svn-related issue.so either mak your project svn or cd to /vendor/plugins and do a svn co svn://rubyforge.org/var/svn/backgroundrb that should work , but remember that won't execute the install.rb script (but that doesnt matter since bgdrb doesnt have that) 2006/8/8, Fernand Galiana : > > Hi, > > I am running ruby 1.8.4 rails 1.1 on Mac OSx and I am getting the > following error installing the plugin. Any ideas ? ( BTW This is a brand new > rails app ) > > Thanks !! > > ruby script/plugin install svn://rubyforge.org/var/svn/backgroundrb > --force > subversion/libsvn_wc/lock.c:630: (apr_err=155007) > svn: '/Users/fgaliana/work/samples/fred/vendor/plugins' is not a working > copy > /usr/local/lib/ruby/1.8/open-uri.rb:88:in `initialize': No such file or > directory - svn://rubyforge.org/var/svn/backgroundrb (Errno::ENOENT) > from /usr/local/lib/ruby/1.8/open-uri.rb:88:in `open' > from /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/commands/plugin.rb:858:in > `fetch_dir' > from /usr/local/lib/ruby/gems/1.8/gems/rails- 1.1.0/lib/commands/plugin.rb:852:in > `fetch' > from /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/commands/plugin.rb:851:in > `fetch' > from /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/commands/plugin.rb:218:in > `install_using_http' > from /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/commands/plugin.rb:168:in > `install' > from /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/commands/plugin.rb:733:in > `parse!' > from /usr/local/lib/ruby/gems/1.8/gems/rails- 1.1.0/lib/commands/plugin.rb:731:in > `parse!' > from /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/commands/plugin.rb:446:in > `parse!' > from /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/commands/plugin.rb:462:in > `parse!' > from /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.0 > /lib/commands/plugin.rb:866 > from > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require' > from /usr/local/lib/ruby/gems/1.8/gems/activesupport- 1.3.0/lib/active_support/dependencies.rb:136:in > `require' > from script/plugin:3 > > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel > > -- Michael Siebert www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060808/06856cfa/attachment-0001.html From hughes.james at gmail.com Tue Aug 8 13:09:34 2006 From: hughes.james at gmail.com (James Hughes) Date: Tue, 8 Aug 2006 10:09:34 -0700 Subject: [Backgroundrb-devel] "include DRbUndumped" error In-Reply-To: References: Message-ID: <765a2c230608081009k245ae1a0j68757016a270e46@mail.gmail.com> Hi Philip, I had similar problems due to the fact that I was storing objects of the class that included DrbUndumped in the rails session variable. I had similar looking stack traces to what you have included here. Don't store the whole object in the session, just store the id and use find() to get the object. hth, James On 8/7/06, Philip Lipu Tsai wrote: > Hi, > > I am getting my hands on trying the cool BackgrounDrb plugin. > Following various discussions and suggestsion, I included "include DRbUndumped" > in my ActiveRecord model. However, the following exception occurs > after I tried this and hit the page that uses this model. Does anyone > know why this is so? Is it possible that an object cannot be > DRbUndumped (that would mean, we can't ever pass a reference to such > object across DRb for BackgrounDrb to process)? > > Thanks! > Philip > > > TypeError (can't dump): > /usr/lib/ruby/1.8/drb/drb.rb:395:in `_dump' > /usr/lib/ruby/1.8/pstore.rb:348:in `dump' > /usr/lib/ruby/1.8/pstore.rb:326:in `transaction' > /usr/lib/ruby/1.8/cgi/session/pstore.rb:90:in `update' > /usr/lib/ruby/1.8/cgi/session/pstore.rb:97:in `close' > /usr/lib/ruby/1.8/cgi/session.rb:330:in `close' > /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/base.rb: > 984:in `close_session' > /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/base.rb: > 1026:in `process_cleanup_without_flash' > /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/flash.rb > :147:in `process_cleanup_without_filters' > /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/filters. > rb:439:in `process_cleanup_without_session_management_support' > /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/session_ > management.rb:126:in `process_cleanup_without_components' > /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/componen > ts.rb:182:in `process_cleanup' > /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/base.rb: > 385:in `process_without_filters' > /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/filters. > rb:377:in `process_without_session_management_support' > /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/session_ > management.rb:117:in `process' > /usr/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/dispatcher.rb:38:in `dispatch' > /usr/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/webrick_server.rb:115:in `handle > _dispatch' > /usr/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/webrick_server.rb:81:in `service > ' > /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service' > /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run' > /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread' > /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread' > /usr/lib/ruby/1.8/webrick/server.rb:95:in `start' > /usr/lib/ruby/1.8/webrick/server.rb:92:in `start' > /usr/lib/ruby/1.8/webrick/server.rb:23:in `start' > /usr/lib/ruby/1.8/webrick/server.rb:82:in `start' > /usr/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/webrick_server.rb:67:in `dispatc > h' > /usr/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/commands/servers/webrick.rb:59 > /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require' > /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependenc > ies.rb:147:in `require' > /usr/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/commands/server.rb:30 > /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require' > /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependenc > ies.rb:147:in `require' > script/server:3 > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel > -- James Hughes Web application developer Vancouver, BC "Developing a coherent political analysis is in many respects contingent upon an ability to connect one context to another, a process not dissimilar to playing the kid's game of dot-to-dot." - Ward Churchill, from '"A Government of Laws"?' From tsailipu at gmail.com Tue Aug 8 13:41:30 2006 From: tsailipu at gmail.com (Philip Lipu Tsai) Date: Tue, 8 Aug 2006 10:41:30 -0700 Subject: [Backgroundrb-devel] "include DRbUndumped" error In-Reply-To: <765a2c230608081009k245ae1a0j68757016a270e46@mail.gmail.com> References: <765a2c230608081009k245ae1a0j68757016a270e46@mail.gmail.com> Message-ID: Thanks James! You are right on! What I have, though, was an object in the session that referenced this model object, so when accessed, this model object got stored in the session as well. Erza also pointed that out to me last night. I also am going to try to see whether instead of passing object references across DRb, simply passing the object IDs, looking them up through DB on the Worker and then manipulating them completely locally on the Worker side will be faster than marshalling/manipulating across DRb in several trips. (I guess this would be a test of DB vs marshalling.) If it turns out to be faster to manipulate through DB locally in the Worker, maybe this could become another best-practice tip to the new comers. On 8/8/06, James Hughes wrote: > Hi Philip, > > I had similar problems due to the fact that I was storing objects of > the class that included DrbUndumped in the rails session variable. I > had similar looking stack traces to what you have included here. Don't > store the whole object in the session, just store the id and use > find() to get the object. > > hth, > James > > On 8/7/06, Philip Lipu Tsai wrote: > > Hi, > > > > I am getting my hands on trying the cool BackgrounDrb plugin. > > Following various discussions and suggestsion, I included "include DRbUndumped" > > in my ActiveRecord model. However, the following exception occurs > > after I tried this and hit the page that uses this model. Does anyone > > know why this is so? Is it possible that an object cannot be > > DRbUndumped (that would mean, we can't ever pass a reference to such > > object across DRb for BackgrounDrb to process)? > > > > Thanks! > > Philip > > > > > > TypeError (can't dump): > > /usr/lib/ruby/1.8/drb/drb.rb:395:in `_dump' > > /usr/lib/ruby/1.8/pstore.rb:348:in `dump' > > /usr/lib/ruby/1.8/pstore.rb:326:in `transaction' > > /usr/lib/ruby/1.8/cgi/session/pstore.rb:90:in `update' > > /usr/lib/ruby/1.8/cgi/session/pstore.rb:97:in `close' > > /usr/lib/ruby/1.8/cgi/session.rb:330:in `close' > > /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/base.rb: > > 984:in `close_session' > > /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/base.rb: > > 1026:in `process_cleanup_without_flash' > > /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/flash.rb > > :147:in `process_cleanup_without_filters' > > /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/filters. > > rb:439:in `process_cleanup_without_session_management_support' > > /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/session_ > > management.rb:126:in `process_cleanup_without_components' > > /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/componen > > ts.rb:182:in `process_cleanup' > > /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/base.rb: > > 385:in `process_without_filters' > > /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/filters. > > rb:377:in `process_without_session_management_support' > > /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/session_ > > management.rb:117:in `process' > > /usr/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/dispatcher.rb:38:in `dispatch' > > /usr/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/webrick_server.rb:115:in `handle > > _dispatch' > > /usr/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/webrick_server.rb:81:in `service > > ' > > /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service' > > /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run' > > /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread' > > /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread' > > /usr/lib/ruby/1.8/webrick/server.rb:95:in `start' > > /usr/lib/ruby/1.8/webrick/server.rb:92:in `start' > > /usr/lib/ruby/1.8/webrick/server.rb:23:in `start' > > /usr/lib/ruby/1.8/webrick/server.rb:82:in `start' > > /usr/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/webrick_server.rb:67:in `dispatc > > h' > > /usr/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/commands/servers/webrick.rb:59 > > /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require' > > /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependenc > > ies.rb:147:in `require' > > /usr/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/commands/server.rb:30 > > /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require' > > /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependenc > > ies.rb:147:in `require' > > script/server:3 > > _______________________________________________ > > Backgroundrb-devel mailing list > > Backgroundrb-devel at rubyforge.org > > http://rubyforge.org/mailman/listinfo/backgroundrb-devel > > > > > -- > James Hughes > Web application developer > Vancouver, BC > > "Developing a coherent political analysis is in many respects > contingent upon an ability to connect one context to another, a > process not dissimilar to playing the kid's game of dot-to-dot." > - Ward Churchill, from '"A Government of Laws"?' > From tsailipu at gmail.com Tue Aug 8 17:43:13 2006 From: tsailipu at gmail.com (Philip Lipu Tsai) Date: Tue, 8 Aug 2006 14:43:13 -0700 Subject: [Backgroundrb-devel] [ANN] New Release Message-ID: Erza, I just tried to update to the new release. Upon start, this is the error: script/backgroundrb/start:100: private method `new' called for BackgrounDRb::Mid dleMan:Class (NoMethodError) Philip From tsailipu at gmail.com Tue Aug 8 18:04:13 2006 From: tsailipu at gmail.com (Philip Lipu Tsai) Date: Tue, 8 Aug 2006 15:04:13 -0700 Subject: [Backgroundrb-devel] [ANN] New Release In-Reply-To: References: Message-ID: Solved. Interesting. Actually I found out that by re-installing/upgrading, I need to nuke the script directory first so that "rake backgroundrb:setup" will generate/copy over the new scripts as well. (The initial README mentions blowing away only the config/backgroundrb.yml.) Although now two warning lines (very syntactic): script/backgroundrb/start:94: warning: don't put space before argument parentheses script/backgroundrb/start:104: warning: don't put space before argument parentheses (BTW, sorry about hitting the wrong option and posting a new message instead of a reply for this correspondence) On 8/8/06, Philip Lipu Tsai wrote: > Erza, > > I just tried to update to the new release. Upon start, this is the error: > > script/backgroundrb/start:100: private method `new' called for BackgrounDRb::Mid > dleMan:Class (NoMethodError) > > Philip > From ezmobius at gmail.com Tue Aug 8 18:41:15 2006 From: ezmobius at gmail.com (Ezra Zygmuntowicz) Date: Tue, 8 Aug 2006 15:41:15 -0700 Subject: [Backgroundrb-devel] [ANN] New Release In-Reply-To: References: Message-ID: Hey- Yeah sorry I should have mentioned that you need to blow away the script/backgroundrb dir and reinstall to do an upgrade. I fixed the warning as well and checked it in again. Thanks- -Ezra On Aug 8, 2006, at 3:04 PM, Philip Lipu Tsai wrote: > Solved. Interesting. Actually I found out that by > re-installing/upgrading, I need to nuke the script directory first so > that "rake backgroundrb:setup" will generate/copy over the new scripts > as well. (The initial README mentions blowing away only the > config/backgroundrb.yml.) > > Although now two warning lines (very syntactic): > > script/backgroundrb/start:94: warning: don't put space before argument > parentheses > script/backgroundrb/start:104: warning: don't put space before > argument parentheses > > (BTW, sorry about hitting the wrong option and posting a new message > instead of a reply for this correspondence) > > > On 8/8/06, Philip Lipu Tsai wrote: >> Erza, >> >> I just tried to update to the new release. Upon start, this is >> the error: >> >> script/backgroundrb/start:100: private method `new' called for >> BackgrounDRb::Mid >> dleMan:Class (NoMethodError) >> >> Philip >> > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel From tsailipu at gmail.com Wed Aug 9 01:33:46 2006 From: tsailipu at gmail.com (Philip Lipu Tsai) Date: Tue, 8 Aug 2006 22:33:46 -0700 Subject: [Backgroundrb-devel] Worker and ActiveRecord Message-ID: Ezra or anyone experienced that may have the insight: When I first fetch an ActiveRecord model inside the Worker and invoke a method in the model, which uses logger, why is it that the logger is not defined? This throws me off a bit as it seems that the code space, e.g. Worker, would know about the Rails context? Or this is not the case? I notice that if the model is already fetched by the application first (e.g. through a preceding web request that also fetches the same model), then logger is defined when the model in the Worker accesses the logger. Seeing this, when I put "Rails::Initializer.run" atop my Worker class, logger is then available when I first invoke that method in the model.... Thoughts? Thanks! Philip From info at siebert-wd.de Wed Aug 9 02:27:28 2006 From: info at siebert-wd.de (Michael Siebert) Date: Wed, 9 Aug 2006 08:27:28 +0200 Subject: [Backgroundrb-devel] [ANN] New Release In-Reply-To: References: Message-ID: <32b567370608082327w63e1dd3v8160cefcd475219f@mail.gmail.com> possibly you could use the setup.rb to copy over the scripts in next release? 2006/8/9, Ezra Zygmuntowicz : > > Hey- > > Yeah sorry I should have mentioned that you need to blow away the > script/backgroundrb dir and reinstall to do an upgrade. I fixed the > warning as well and checked it in again. > > Thanks- > -Ezra > > On Aug 8, 2006, at 3:04 PM, Philip Lipu Tsai wrote: > > > Solved. Interesting. Actually I found out that by > > re-installing/upgrading, I need to nuke the script directory first so > > that "rake backgroundrb:setup" will generate/copy over the new scripts > > as well. (The initial README mentions blowing away only the > > config/backgroundrb.yml.) > > > > Although now two warning lines (very syntactic): > > > > script/backgroundrb/start:94: warning: don't put space before argument > > parentheses > > script/backgroundrb/start:104: warning: don't put space before > > argument parentheses > > > > (BTW, sorry about hitting the wrong option and posting a new message > > instead of a reply for this correspondence) > > > > > > On 8/8/06, Philip Lipu Tsai wrote: > >> Erza, > >> > >> I just tried to update to the new release. Upon start, this is > >> the error: > >> > >> script/backgroundrb/start:100: private method `new' called for > >> BackgrounDRb::Mid > >> dleMan:Class (NoMethodError) > >> > >> Philip > >> > > _______________________________________________ > > Backgroundrb-devel mailing list > > Backgroundrb-devel at rubyforge.org > > http://rubyforge.org/mailman/listinfo/backgroundrb-devel > > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel > -- Michael Siebert www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060809/304c3121/attachment-0001.html From truangde at gmail.com Wed Aug 9 16:06:44 2006 From: truangde at gmail.com (Tee) Date: Wed, 9 Aug 2006 13:06:44 -0700 Subject: [Backgroundrb-devel] Need help with backgroundrb's concepts and installation Message-ID: <9e6709750608091306j60e975a2kf918a57ed32aa6bf@mail.gmail.com> Hello backgroundrb-devel my name is Teeranit Ruangdet. I'm fairly new to Ruby on Rails so please bear with me here. I'm currently on a project where I need to import a whole bunch of records from spreadsheet(.csv) and save them in the database. My problem is that while I'm importing (huge file...say 5000 employees), no one else can access the website (it basically block everybody out from the server including myself. It will gain back the access when it finished importing which takes about 45 minutes because of all the business rules) so my friends recommended me to look up into backgroundrb and here I am ;) So my first question to you is. Is backgroundrb what I needed to solved my problem? All I need is for my program to be able to import a file to the database and allow other people to access the website at the same time (perhaps make some changes with a different table on the same database .. it's ok to not be able to make change to emoployee's table while it's importing). Second question, if backgroundrb is perfect for this scenario, how do I install it? I use window machine and I follow the instructions from this link (http://backgroundrb.rubyforge.org/) in order to install backgroundrb but it doesn't seem to work right here is how I install backgroundrb ( btw, my project name is called ttv3) 1. I ran C:\InstantRails-1.0\rails_apps\ttv3>ruby script/plugin install svn://rubyforge.org//var/svn/backgroundrb 2. it seems to be loading something for a second 3. then I input C:\InstantRails-1.0\rails_apps\ttv3>rake backgroundrb:setup but then I got this error message C:\InstantRails-1.0\rails_apps\ttv3>rake backgroundrb:setup (in C:/InstantRails-1.0/rails_apps/ttv3) rake aborted! Don't know how to build task 'backgroundrb:setup' (See full trace by running task with --trace) What did I do wrong? Please advise Regards, Teeranit Ruangdet -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060809/f680fce7/attachment.html From ezmobius at gmail.com Wed Aug 9 16:16:55 2006 From: ezmobius at gmail.com (Ezra Zygmuntowicz) Date: Wed, 9 Aug 2006 13:16:55 -0700 Subject: [Backgroundrb-devel] Need help with backgroundrb's concepts and installation In-Reply-To: <9e6709750608091306j60e975a2kf918a57ed32aa6bf@mail.gmail.com> References: <9e6709750608091306j60e975a2kf918a57ed32aa6bf@mail.gmail.com> Message-ID: <67532973-3666-4669-8CDF-DC441008FA7C@gmail.com> On Aug 9, 2006, at 1:06 PM, Tee wrote: > Hello backgroundrb-devel > my name is Teeranit Ruangdet. I'm fairly new to Ruby on Rails so > please bear with me here. > I'm currently on a project where I need to import a whole bunch of > records from spreadsheet(.csv) and save them in the database. My > problem is that while I'm importing (huge file...say 5000 > employees), no one else can access the website (it basically block > everybody out from the server including myself. It will gain back > the access when it finished importing which takes about 45 minutes > because of all the business rules) so my friends recommended me to > look up into backgroundrb and here I am ;) > > So my first question to you is. Is backgroundrb what I needed to > solved my problem? All I need is for my program to be able to > import a file to the database and allow other people to access the > website at the same time (perhaps make some changes with a > different table on the same database .. it's ok to not be able to > make change to emoployee's table while it's importing). > > Second question, if backgroundrb is perfect for this scenario, how > do I install it? I use window machine and I follow the instructions > from this link (http://backgroundrb.rubyforge.org/ ) in order to > install backgroundrb but it doesn't seem to work right > > here is how I install backgroundrb ( btw, my project name is > called ttv3) > 1. I ran > > C:\InstantRails-1.0\rails_apps\ttv3> ruby script/plugin install > svn://rubyforge.org//var/svn/backgroundrb > > 2. it seems to be loading something for a second > 3. then I input > > C:\InstantRails-1.0\rails_apps\ttv3>rake backgroundrb:setup > > but then I got this error message > > C:\InstantRails-1.0\rails_apps\ttv3>rake backgroundrb:setup > (in C:/InstantRails-1.0/rails_apps/ttv3) > rake aborted! > Don't know how to build task 'backgroundrb:setup' > > (See full trace by running task with --trace) > > > What did I do wrong? Please advise > > Regards, > Teeranit Ruangdet Welcome Teeranit- Yes I think backgroudrb is the perfect plugin for what you need to do. You have to have subversion installed to be able to use script/ plugin install on this plugin. Do you have svn or subversion installed? Also can you tell me the exact output from the console when you try to install it? THe error about not know the task is because the plugin was not installed correctly. -Ezra -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060809/34d924e6/attachment.html From cameron at theworkinggroup.ca Wed Aug 9 18:30:31 2006 From: cameron at theworkinggroup.ca (Cameron Booth) Date: Wed, 9 Aug 2006 18:30:31 -0400 Subject: [Backgroundrb-devel] Need help with backgroundrb's concepts and installation Message-ID: Hi all, I have a similar issue in my new rails app - one process, generating a PDF takes up way too much memory/processor in some cases (when there are a lot of pages), taking down my server for other users. Looks like BackgrounDrb will help distribute that? Again, I'm just getting started now, but my question - is there a way to ensure that tasks I farm out to a MiddleMan won't take up tonnes of server processing? Can I "nice" them, or make them lower priority or something? Any advice greatly appreciated!! And Ezra, saw you speak at RailsConf, was a good one....I'm now at RailsMachine, putting Mongrel through it's paces....aside from this, seems to be going well! Cheers, Cameron On Aug 9, 2006, at 1:06 PM, Tee wrote: > Hello backgroundrb-devel > my name is Teeranit Ruangdet. I'm fairly new to Ruby on Rails so > please bear with me here. > I'm currently on a project where I need to import a whole bunch of > records from spreadsheet(.csv) and save them in the database. My > problem is that while I'm importing (huge file...say 5000 > employees), no one else can access the website (it basically block > everybody out from the server including myself. It will gain back > the access when it finished importing which takes about 45 minutes > because of all the business rules) so my friends recommended me to > look up into backgroundrb and here I am ;) > > So my first question to you is. Is backgroundrb what I needed to > solved my problem? All I need is for my program to be able to > import a file to the database and allow other people to access the > website at the same time (perhaps make some changes with a > different table on the same database .. it's ok to not be able to > make change to emoployee's table while it's importing). > > Second question, if backgroundrb is perfect for this scenario, how > do I install it? I use window machine and I follow the instructions > from this link (http://backgroundrb.rubyforge.org/ ) in order to > install backgroundrb but it doesn't seem to work right > > here is how I install backgroundrb ( btw, my project name is > called ttv3) > 1. I ran > > C:\InstantRails-1.0\rails_apps\ttv3> ruby script/plugin install > svn://rubyforge.org//var/svn/backgroundrb > > 2. it seems to be loading something for a second > 3. then I input > > C:\InstantRails-1.0\rails_apps\ttv3>rake backgroundrb:setup > > but then I got this error message > > C:\InstantRails-1.0\rails_apps\ttv3>rake backgroundrb:setup > (in C:/InstantRails-1.0/rails_apps/ttv3) > rake aborted! > Don't know how to build task 'backgroundrb:setup' > > (See full trace by running task with --trace) > > > What did I do wrong? Please advise > > Regards, > Teeranit Ruangdet Welcome Teeranit- Yes I think backgroudrb is the perfect plugin for what you need to do. You have to have subversion installed to be able to use script/ plugin install on this plugin. Do you have svn or subversion installed? Also can you tell me the exact output from the console when you try to install it? THe error about not know the task is because the plugin was not installed correctly. -Ezra From jedgecombe at carolina.rr.com Wed Aug 9 20:35:05 2006 From: jedgecombe at carolina.rr.com (Jason Edgecombe) Date: Wed, 09 Aug 2006 20:35:05 -0400 Subject: [Backgroundrb-devel] Need help with backgroundrb's concepts and installation In-Reply-To: References: Message-ID: <44DA7F39.3060500@carolina.rr.com> Hi Cameron, Backgroundrb should keep your server responsive while generating the PDF. Backgroundrb runs as a separate process. Because of this, you can nice the process using normal unix or windows Os process priorities. Jason Edgecombe Cameron Booth wrote: > Hi all, > > I have a similar issue in my new rails app - one process, generating > a PDF takes up way too much memory/processor in some cases (when > there are a lot of pages), taking down my server for other users. > > Looks like BackgrounDrb will help distribute that? Again, I'm just > getting started now, but my question - is there a way to ensure that > tasks I farm out to a MiddleMan won't take up tonnes of server > processing? Can I "nice" them, or make them lower priority or something? > > Any advice greatly appreciated!! > > And Ezra, saw you speak at RailsConf, was a good one....I'm now at > RailsMachine, putting Mongrel through it's paces....aside from this, > seems to be going well! > > Cheers, > > Cameron > > > > On Aug 9, 2006, at 1:06 PM, Tee wrote: > > > Hello backgroundrb-devel > > my name is Teeranit Ruangdet. I'm fairly new to Ruby on Rails so > > please bear with me here. > > I'm currently on a project where I need to import a whole bunch of > > records from spreadsheet(.csv) and save them in the database. My > > problem is that while I'm importing (huge file...say 5000 > > employees), no one else can access the website (it basically block > > everybody out from the server including myself. It will gain back > > the access when it finished importing which takes about 45 minutes > > because of all the business rules) so my friends recommended me to > > look up into backgroundrb and here I am ;) > > > > So my first question to you is. Is backgroundrb what I needed to > > solved my problem? All I need is for my program to be able to > > import a file to the database and allow other people to access the > > website at the same time (perhaps make some changes with a > > different table on the same database .. it's ok to not be able to > > make change to emoployee's table while it's importing). > > > > Second question, if backgroundrb is perfect for this scenario, how > > do I install it? I use window machine and I follow the instructions > > from this link (http://backgroundrb.rubyforge.org/ ) in order to > > install backgroundrb but it doesn't seem to work right > > > > here is how I install backgroundrb ( btw, my project name is > > called ttv3) > > 1. I ran > > > > C:\InstantRails-1.0\rails_apps\ttv3> ruby script/plugin install > > svn://rubyforge.org//var/svn/backgroundrb > > > > 2. it seems to be loading something for a second > > 3. then I input > > > > C:\InstantRails-1.0\rails_apps\ttv3>rake backgroundrb:setup > > > > but then I got this error message > > > > C:\InstantRails-1.0\rails_apps\ttv3>rake backgroundrb:setup > > (in C:/InstantRails-1.0/rails_apps/ttv3) > > rake aborted! > > Don't know how to build task 'backgroundrb:setup' > > > > (See full trace by running task with --trace) > > > > > > What did I do wrong? Please advise > > > > Regards, > > Teeranit Ruangdet > > > Welcome Teeranit- > > Yes I think backgroudrb is the perfect plugin for what you need to > do. You have to have subversion installed to be able to use script/ > plugin install on this plugin. Do you have svn or subversion > installed? Also can you tell me the exact output from the console > when you try to install it? THe error about not know the task is > because the plugin was not installed correctly. > > -Ezra > > From matt at chipt.com Thu Aug 10 17:35:13 2006 From: matt at chipt.com (Matt Pennig) Date: Thu, 10 Aug 2006 16:35:13 -0500 Subject: [Backgroundrb-devel] Cleaning up a worker that is about to be killed. Message-ID: <7A047E9F-CFFE-4E4E-9A46-0FFC9D8545AB@chipt.com> I was looking through the code and I am confused. Now, I'm not at all familiar with DRb, so keep that in mind. What I would like to accomplish is letting a worker clean up or perform some other action in case the job goes beyond the time-to- live, or it is otherwise instructed to be killed. I'm running an audio & video converter process, and I want to handle the case where the conversion takes too long -- setting a flag to "Failed", for example. I don't want the job to just get killed... I saw something about @job_ctrl in the comments, but nowhere did I see it actually _used_. Is this implemented by DRb? -Matt Pennig -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060810/91546e8c/attachment.html From eugenol at gmail.com Sat Aug 12 11:07:04 2006 From: eugenol at gmail.com (Eugenol) Date: Sat, 12 Aug 2006 17:07:04 +0200 Subject: [Backgroundrb-devel] Multiple args Message-ID: <8a7ce02e0608120807lf1f5acena2c3f911d4155ca2@mail.gmail.com> Hi It seems the following code do not transfer multiple arguments to the worker instance: controller: ======= # recipients = Hash # mailing = Mailing model instance session[:job_key] = MiddleMan.new_worker( :class => :mail_queue_worker, :args => { :recipients => recipients, :mailing => mailing }, :ttl => 800 ) mail_queue_worker.rb: ================ require File.dirname(__FILE__) + "/../../config/environment.rb" ActionMailer::Base.template_root = File.expand_path(File.dirname(__FILE__) + "/../../app/views") class MailQueueWorker < BackgrounDRb::Rails attr_accessor :progress def do_work(args) @progress = 0 @logger.info("MailQueueWorker: start sending newsletter #{args[:mailing].title}") @logger.info( args.to_s ) for member_email in args[:recipents] Newsletter.deliver_send_mailing(args[:mailing], member_email) @progress += 100/args[:recipents].size end @progress = 100 @logger.info("MailQueueWorker: end sending newsletter #{args[:mailing].title}") end end And I get the following error: You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occured while evaluating nil.each - (NoMethodError) /usr/home/act/mailing/config/../script/backgroundrb/../../config/../lib/workers/mail_queue_worker.rb:17:in `do_work' Is there any mistake I pasted here ? Thanks for your help From fernand.galiana at gmail.com Sat Aug 12 15:28:37 2006 From: fernand.galiana at gmail.com (Fernand Galiana) Date: Sat, 12 Aug 2006 13:28:37 -0600 Subject: [Backgroundrb-devel] RE Multiple args Message-ID: <30ab479c0608121228o6c2f85e0r4b0e7a8bae95fea9@mail.gmail.com> Eugenol, I am new to this framework but looking at your issue I would suggest a couple of things: a) Does the recipients hash have anything in it prior to the call b) Why type of object are in recipients ? Can they be marshalled ? -Fernand -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060812/59ea20ad/attachment.html From ezmobius at gmail.com Sat Aug 12 18:48:10 2006 From: ezmobius at gmail.com (Ezra Zygmuntowicz) Date: Sat, 12 Aug 2006 15:48:10 -0700 Subject: [Backgroundrb-devel] Multiple args In-Reply-To: <8a7ce02e0608120807lf1f5acena2c3f911d4155ca2@mail.gmail.com> References: <8a7ce02e0608120807lf1f5acena2c3f911d4155ca2@mail.gmail.com> Message-ID: <127D8EF7-D6B6-4678-9975-99429B536D56@gmail.com> Hi Eugene- I think there must be an error somewhere. Can you show me what the output is if you do @logger args.inspect right at the beginning of your do_work method. then look in the log file and show us what is output. Also if :recipients is a hash then you need to treat it like one. So this: for member_email in args[:recipents] Newsletter.deliver_send_mailing(args[:mailing], member_email) @progress += 100/args[:recipents].size end Should be something like this args[:recipents].each do |key, val| Newsletter.deliver_send_mailing(args[:mailing], <*>) # replace the <*> with either the key or val # depending on how your hash is structured. @progress += 100/args[:recipents].size # and this won't do what you think it might do. It will # always be the same size as the original entire hash #because you don't delete any members. end I would suggest you test out your code in script/console or something so you know that it works and then put it in a worker. It seems like your args just aren't what you are expecting them to be. If you can paste back the section of the log where you called @logger args.inspect I can help you code up how to use the args correctly. Cheers- -Ezra On Aug 12, 2006, at 8:07 AM, Eugenol wrote: > Hi > > It seems the following code do not transfer multiple arguments to the > worker instance: > > controller: > ======= > # recipients = Hash > # mailing = Mailing model instance > session[:job_key] = MiddleMan.new_worker( :class > => :mail_queue_worker, > :args => { :recipients > => recipients, :mailing => mailing }, > :ttl => 800 ) > > mail_queue_worker.rb: > ================ > > require File.dirname(__FILE__) + "/../../config/environment.rb" > ActionMailer::Base.template_root = > File.expand_path(File.dirname(__FILE__) + "/../../app/views") > > class MailQueueWorker < BackgrounDRb::Rails > > attr_accessor :progress > > def do_work(args) > @progress = 0 > @logger.info("MailQueueWorker: start sending newsletter > #{args[:mailing].title}") > @logger.info( args.to_s ) > for member_email in args[:recipents] > Newsletter.deliver_send_mailing(args[:mailing], member_email) > @progress += 100/args[:recipents].size > end > @progress = 100 > @logger.info("MailQueueWorker: end sending newsletter > #{args[:mailing].title}") > end > > end > > > > And I get the following error: > > You have a nil object when you didn't expect it! > You might have expected an instance of Array. > The error occured while evaluating nil.each - (NoMethodError) > /usr/home/act/mailing/config/../script/backgroundrb/../../config/../ > lib/workers/mail_queue_worker.rb:17:in > `do_work' > > > Is there any mistake I pasted here ? > > Thanks for your help > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel From ezmobius at gmail.com Mon Aug 14 11:41:39 2006 From: ezmobius at gmail.com (Ezra Zygmuntowicz) Date: Mon, 14 Aug 2006 08:41:39 -0700 Subject: [Backgroundrb-devel] [ANN] Minor Release Message-ID: Folks- I just pushed new version of backgroundrb to rubyforge. THis release fixes a bug with thread handling and also adds a few things. Thanks to Chris Hulbert for coding up a win32 service and daemon script. You will need to reinstall the plugin if you already have it and delete the script/backgroundrb dir from your rails project. Then run this command to see windows service usage: > ruby script/backgroundrb/service --help I also finally added a restart rake task. $ rake backgroundrb:restart I would appreciate it if some windows users can test out the service part and let me know if you run into any issues as I don't have a windows box to test on. Cheers- -Ezra From dsisnero at gmail.com Mon Aug 14 12:29:10 2006 From: dsisnero at gmail.com (Dominic Sisneros) Date: Mon, 14 Aug 2006 10:29:10 -0600 Subject: [Backgroundrb-devel] problem updating and installing Message-ID: My work has a firewall that blocks svn traffic. Is there any way that you can put a public websvn like the other plugins so that I and others have the option of installing by the http install method Thanks Dominic -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060814/c9c18fcf/attachment.html From mattp at digimonkey.com Wed Aug 16 13:01:26 2006 From: mattp at digimonkey.com (mattp at digimonkey.com) Date: Wed, 16 Aug 2006 12:01:26 -0500 Subject: [Backgroundrb-devel] newbie needs help Message-ID: <20060816120126.sfhmdzyd0twcs4ok@digimonkey.com> I'm sure this is the billionth newbie help request on here, but I sure am hitting my head against the wall on this. I've tried numberous of Ezra's examples that I was able to find online. The best I'm able to get is nothing happens and development log says: NoMethodError (undefined method `progress' for #): /app/controllers/operations_controller.rb:13:in `get_progress' Any ideas? I'm sure there's a basic thing I'm not doing right... but I couldn't figure out what that might be, based on the documentation. [mp] From ezmobius at gmail.com Wed Aug 16 13:24:18 2006 From: ezmobius at gmail.com (Ezra Zygmuntowicz) Date: Wed, 16 Aug 2006 10:24:18 -0700 Subject: [Backgroundrb-devel] newbie needs help In-Reply-To: <20060816120126.sfhmdzyd0twcs4ok@digimonkey.com> References: <20060816120126.sfhmdzyd0twcs4ok@digimonkey.com> Message-ID: <88CAB41C-6A0D-4A6C-AE1D-E31E338784EF@gmail.com> On Aug 16, 2006, at 10:01 AM, mattp at digimonkey.com wrote: > I'm sure this is the billionth newbie help request on here, but I sure > am hitting my head against the wall on this. > > I've tried numberous of Ezra's examples that I was able to find > online. The best I'm able to get is nothing happens and development > log says: > > NoMethodError (undefined method `progress' for # 0x3a786c0>): > /app/controllers/operations_controller.rb:13:in `get_progress' > > Any ideas? I'm sure there's a basic thing I'm not doing right... but > I couldn't figure out what that might be, based on the documentation. > > [mp] > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel > Hi Matt- It looks like you are missing something. Can you post your worker class? It looks like you either need a progress method or you need to set attr_accessor :progress in your worker. -Ezra From ezmobius at gmail.com Wed Aug 16 13:38:34 2006 From: ezmobius at gmail.com (Ezra Zygmuntowicz) Date: Wed, 16 Aug 2006 10:38:34 -0700 Subject: [Backgroundrb-devel] Forward of moderated message In-Reply-To: <20060816122506.1w2qkrus7k7ocgck@digimonkey.com> References: <4F966DB6-838C-4E83-9B9B-AF4C63299963@gmail.com> <20060816122506.1w2qkrus7k7ocgck@digimonkey.com> Message-ID: <28FB7167-3BE4-4E8D-8E27-F7B50FBAB7B0@gmail.com> OK I know whats happening. Your while loop completes and calls kill on the worker before your task_progress controller method ever gets called> So the worker is deleted and when you try to access it from rails you get an error because there is no longer a worker at that job key. The kill method is meant to be used within a worker that you fire and forget. If you want to get the results then you should not call kill right in your worker. You can call kill or delete_worker from rails in your done method. So if you want to see the progress bar working I suggest you put a sleep in the while loop. A while loop with no sleep can count to 1200 before you could blink and then the kill method gets called and your screwed. So add sleep 0.3 or somethign within the while loop so you can see it work. And if you want to see the results of your worker in rails you should call the kill method from rails through the middlwman. If you want to just fire and forget a worker then you want to call kill within the worker when it is done working. Other then that your code is fine. Give it another shot with some sleep in the loop. Cheers- -Ezra On Aug 16, 2006, at 10:25 AM, mattp at digimonkey.com wrote: > Weird is, I had it working a second ago and then reloaded the > webrick server and now it's erroring out with: > > NoMethodError (You have a nil object when you didn't expect it! > The error occured while evaluating nil.progress): > /app/controllers/operations_controller.rb:14:in `task_progress' > > Here's the code -- > > [ /lib/workers/ping_worker.rb ] > > class PingWorker < BackgrounDRb::Rails > > attr_accessor :progress > > def do_work(args) > @progress = 0 > calculate_the_meaning_of_life(args) > kill > end > > def calculate_the_meaning_of_life(args) > while @progress < 100 > @progress += 1 > end > end > > end > > [ operations_controller.rb ] > > class OperationsController < ApplicationController > sidebar :general > sidebar :operations > > # start new worker and put the job_key into the session so you can > # get the status of your job later. > def background_task > session[:job_key] = MiddleMan.new_worker(:class => :ping_worker, > :args => {:baz => > 'hello!', :qux => 'another arg!'}) > end > > def task_progress > if request.xhr? > progress_percent = MiddleMan.get_worker(session > [:job_key]).progress > render :update do |page| > page.call('progressPercent', 'progressbar', progress_percent) > page.redirect_to( :action => 'done') if progress_percent >= > 100 > end > else > redirect_to :action => 'index' > end > end > > def results > @results = MiddleMan.get_worker(session[:job_key]).results > MiddleMan.delete_worker(session[:job_key]) > end > > def done > end > > end > > Quoting Ezra Zygmuntowicz : > >> >> On Aug 16, 2006, at 10:08 AM, backgroundrb-devel- >> bounces at rubyforge.org wrote: >> >>> >>> From: mattp at digimonkey.com >>> Date: August 16, 2006 10:01:26 AM PDT >>> To: backgroundrb-devel at rubyforge.org >>> Subject: newbie needs help >>> >>> >>> I'm sure this is the billionth newbie help request on here, but >>> I sure am hitting my head against the wall on this. >>> >>> I've tried numberous of Ezra's examples that I was able to find >>> online. The best I'm able to get is nothing happens and >>> development log says: >>> >>> NoMethodError (undefined method `progress' for #>> 0x3a786c0>): >>> /app/controllers/operations_controller.rb:13:in `get_progress' >>> >>> Any ideas? I'm sure there's a basic thing I'm not doing >>> right... but I couldn't figure out what that might be, based on >>> the documentation. >>> >>> [mp] >>> >>> >> >> >> Hi Matt- >> >> It looks like you are missing something. Can you post your worker >> class? It looks like you either need a progress method or you need to >> set attr_accessor :progress in your worker. >> >> >> -Ezra > > From mattp at digimonkey.com Wed Aug 16 13:48:03 2006 From: mattp at digimonkey.com (mattp at digimonkey.com) Date: Wed, 16 Aug 2006 12:48:03 -0500 Subject: [Backgroundrb-devel] Forward of moderated message In-Reply-To: <28FB7167-3BE4-4E8D-8E27-F7B50FBAB7B0@gmail.com> References: <4F966DB6-838C-4E83-9B9B-AF4C63299963@gmail.com> <20060816122506.1w2qkrus7k7ocgck@digimonkey.com> <28FB7167-3BE4-4E8D-8E27-F7B50FBAB7B0@gmail.com> Message-ID: <20060816124803.jnxb7v6jb48wck0w@digimonkey.com> That did it. Thanks! As a note that might be helpful to others -- If you are using windows and RadRails for development, you need to be sure and restart the backgroundrb server in your cmd.exe console window after you make changes to the *_worker.rb files. I'm sure Ezra can explain why (I can't.) Ok, so for my next question: Now that my stupid progress counter is working, on to what I really want to do -- run a system-level command like 'ping -t www.google.com' and have it periodically update a
with the command's ouput. Is this possible? [mp] Quoting Ezra Zygmuntowicz : > OK I know whats happening. Your while loop completes and calls kill on > the worker before your task_progress controller method ever gets > called> So the worker is deleted and when you try to access it from > rails you get an error because there is no longer a worker at that job > key. The kill method is meant to be used within a worker that you fire > and forget. If you want to get the results then you should not call > kill right in your worker. You can call kill or delete_worker from > rails in your done method. > > So if you want to see the progress bar working I suggest you put a > sleep in the while loop. A while loop with no sleep can count to 1200 > before you could blink and then the kill method gets called and your > screwed. So add sleep 0.3 or somethign within the while loop so you can > see it work. > > And if you want to see the results of your worker in rails you should > call the kill method from rails through the middlwman. If you want to > just fire and forget a worker then you want to call kill within the > worker when it is done working. > > Other then that your code is fine. Give it another shot with some > sleep in the loop. > > Cheers- > -Ezra > > > > On Aug 16, 2006, at 10:25 AM, mattp at digimonkey.com wrote: > >> Weird is, I had it working a second ago and then reloaded the >> webrick server and now it's erroring out with: >> >> NoMethodError (You have a nil object when you didn't expect it! >> The error occured while evaluating nil.progress): >> /app/controllers/operations_controller.rb:14:in `task_progress' >> >> Here's the code -- >> >> [ /lib/workers/ping_worker.rb ] >> >> class PingWorker < BackgrounDRb::Rails >> >> attr_accessor :progress >> >> def do_work(args) >> @progress = 0 >> calculate_the_meaning_of_life(args) >> kill >> end >> >> def calculate_the_meaning_of_life(args) >> while @progress < 100 >> @progress += 1 >> end >> end >> >> end >> >> [ operations_controller.rb ] >> >> class OperationsController < ApplicationController >> sidebar :general >> sidebar :operations >> >> # start new worker and put the job_key into the session so you can >> # get the status of your job later. >> def background_task >> session[:job_key] = MiddleMan.new_worker(:class => :ping_worker, >> :args => {:baz => >> 'hello!', :qux => 'another arg!'}) >> end >> >> def task_progress >> if request.xhr? >> progress_percent = MiddleMan.get_worker(session[:job_key]).progress >> render :update do |page| >> page.call('progressPercent', 'progressbar', progress_percent) >> page.redirect_to( :action => 'done') if progress_percent >= 100 >> end >> else >> redirect_to :action => 'index' >> end >> end >> >> def results >> @results = MiddleMan.get_worker(session[:job_key]).results >> MiddleMan.delete_worker(session[:job_key]) >> end >> >> def done >> end >> >> end >> >> Quoting Ezra Zygmuntowicz : >> >>> >>> On Aug 16, 2006, at 10:08 AM, backgroundrb-devel- >>> bounces at rubyforge.org wrote: >>> >>>> >>>> From: mattp at digimonkey.com >>>> Date: August 16, 2006 10:01:26 AM PDT >>>> To: backgroundrb-devel at rubyforge.org >>>> Subject: newbie needs help >>>> >>>> >>>> I'm sure this is the billionth newbie help request on here, but I >>>> sure am hitting my head against the wall on this. >>>> >>>> I've tried numberous of Ezra's examples that I was able to find >>>> online. The best I'm able to get is nothing happens and >>>> development log says: >>>> >>>> NoMethodError (undefined method `progress' for #): >>>> /app/controllers/operations_controller.rb:13:in `get_progress' >>>> >>>> Any ideas? I'm sure there's a basic thing I'm not doing right... >>>> but I couldn't figure out what that might be, based on the >>>> documentation. >>>> >>>> [mp] >>>> >>>> >>> >>> >>> Hi Matt- >>> >>> It looks like you are missing something. Can you post your worker >>> class? It looks like you either need a progress method or you need to >>> set attr_accessor :progress in your worker. >>> >>> >>> -Ezra >> >> From mattp at digimonkey.com Wed Aug 16 16:14:44 2006 From: mattp at digimonkey.com (mattp at digimonkey.com) Date: Wed, 16 Aug 2006 15:14:44 -0500 Subject: [Backgroundrb-devel] "tailing" a running system command? In-Reply-To: <20060816124803.jnxb7v6jb48wck0w@digimonkey.com> References: <4F966DB6-838C-4E83-9B9B-AF4C63299963@gmail.com> <20060816122506.1w2qkrus7k7ocgck@digimonkey.com> <28FB7167-3BE4-4E8D-8E27-F7B50FBAB7B0@gmail.com> <20060816124803.jnxb7v6jb48wck0w@digimonkey.com> Message-ID: <20060816151444.yc5xuiao9yysggso@digimonkey.com> Dunno if anyone saw the short question at the end of my last thread, so i'm reposting in a thread with the appropriate subject: Here's what I need to do -- Run a system-level command like 'ping -t www.google.com' and have it periodically update a
with the command's ouput. Is this possible? (the trick here is that I want *periodic* updates of the div... i want to see incremental output as 'ping' is running, just like if I were looking at console...) From gladwig at gmx.de Wed Aug 16 16:31:47 2006 From: gladwig at gmx.de (=?ISO-8859-1?Q?G=FCnter_Ladwig?=) Date: Wed, 16 Aug 2006 22:31:47 +0200 Subject: [Backgroundrb-devel] "tailing" a running system command? In-Reply-To: <20060816151444.yc5xuiao9yysggso@digimonkey.com> References: <4F966DB6-838C-4E83-9B9B-AF4C63299963@gmail.com> <20060816122506.1w2qkrus7k7ocgck@digimonkey.com> <28FB7167-3BE4-4E8D-8E27-F7B50FBAB7B0@gmail.com> <20060816124803.jnxb7v6jb48wck0w@digimonkey.com> <20060816151444.yc5xuiao9yysggso@digimonkey.com> Message-ID: <1D79F299-D1E4-4C3B-B0FB-88EE42BC602F@gmx.de> On 16.08.2006, at 22:14, mattp at digimonkey.com wrote: > Run a system-level command like 'ping -t www.google.com' and have it > periodically update a
with the command's ouput. Is this > possible? > > (the trick here is that I want *periodic* updates of the div... i want > to see incremental output as 'ping' is running, just like if I were > looking at console...) Yes, it should be possible. Have a look at the Rails function periodically_call_remote. In the controller method you could then get the output from your worker and replace the HTML in a particular
-tag. G?nter From me at seebq.com Wed Aug 16 17:19:49 2006 From: me at seebq.com (Charles Brian Quinn) Date: Wed, 16 Aug 2006 17:19:49 -0400 Subject: [Backgroundrb-devel] "tailing" a running system command? In-Reply-To: <20060816151444.yc5xuiao9yysggso@digimonkey.com> References: <4F966DB6-838C-4E83-9B9B-AF4C63299963@gmail.com> <20060816122506.1w2qkrus7k7ocgck@digimonkey.com> <28FB7167-3BE4-4E8D-8E27-F7B50FBAB7B0@gmail.com> <20060816124803.jnxb7v6jb48wck0w@digimonkey.com> <20060816151444.yc5xuiao9yysggso@digimonkey.com> Message-ID: <3a2de0cd0608161419j64b1b321j1360157740b2e0bf@mail.gmail.com> We're working on a super cool new tool to help automate capistrano and rake deployment task running on remote servers, and we do something similiar to this using backgrounDRb (thanks Ezra!). It is based off our RailsDay 2006 entry: http://heartbeat.highgroove.com/ -- enough with the bragging, here is how we do it: your worker now needs to have an @output class variable (instead of progress). in your worker, you can run the task one of two ways which might or might not work: # you can use Kernel.system to make the call which I don't know how you get output if not Kernel.system("ping google) errors.add_to_base(" your error here ") # this is technically in a model hence the errors obj raise end # or: cmd_to_run = "ping google" stdin, stdout, stderr = Open3.popen3(cmd_to_run) s_stderr = stderr.read.to_s s_stdout = stdout.read.to_s # if you'd like to see it logger.info "stdout: #{s_stdout}" logger.info "stderr: #{s_stderr}" if s_stderr.empty? && s_stdout.starts_with?("error stuff here") return true else errors.add_to_base("error msg here") return false end But, as for setting your @output, well, you'd need to run inside a loop or perhaps even in another thread within the bg worker thread. We don't need to do this because we're executing our task using ssh and we have an open channel and just do @output << in the loop as it runs. You may not be able to use the popen3 calls above, to be honest -- the read pretty much kills that idea. Our worker method that appends output looks like: Net::SSH.start( host, :username => username, :password => password, :port => port ) do |session| session.open_channel do |channel| channel.on_data do |ch, data| @output << "#{data}" end channel.on_extended_data do |ch, type, data| @output << "#{data}" end channel.exec( "ping google\n" ) end session.loop end Maybe you can find a simliar asynchronous call for executing methods, that updates output as it runs. Now, in your controller: the method, let's say execute: def execute session[:job_key] = Middleman.... # call your worker end and for the view we used rjs to update a page (a lightbox actually):
Connecting to Server...
execute.rjs: page << "showBG();" page << "showIbox('#{url_for(:action => 'output', :id => @task)}','',parseQuery('width=760&height=400'))" page << "output = new Ajax.PeriodicalUpdater('task_output','#{url_for(:action => 'update_output', :id=> @task.id)}',2);" back to your controller, it can be as simple as: def update_output @job = MiddleMan.get_worker(session[:job_key]) render :inline => '<%= simple_format(@job.output) %>' end The hard part will be appending @output as it's running. I know I didn't answer the @output side, but hopefully helped with the backgroundrb worker side. cheers and good luck, let us know how it goes. On 8/16/06, mattp at digimonkey.com wrote: > Dunno if anyone saw the short question at the end of my last thread, > so i'm reposting in a thread with the appropriate subject: > > Here's what I need to do -- > > Run a system-level command like 'ping -t www.google.com' and have it > periodically update a
with the command's ouput. Is this possible? > > (the trick here is that I want *periodic* updates of the div... i want > to see incremental output as 'ping' is running, just like if I were > looking at console...) > _______________________________________________ > 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 From mattp at digimonkey.com Wed Aug 16 17:47:23 2006 From: mattp at digimonkey.com (mattp at digimonkey.com) Date: Wed, 16 Aug 2006 16:47:23 -0500 Subject: [Backgroundrb-devel] "tailing" a running system command? In-Reply-To: <3a2de0cd0608161419j64b1b321j1360157740b2e0bf@mail.gmail.com> References: <4F966DB6-838C-4E83-9B9B-AF4C63299963@gmail.com> <20060816122506.1w2qkrus7k7ocgck@digimonkey.com> <28FB7167-3BE4-4E8D-8E27-F7B50FBAB7B0@gmail.com> <20060816124803.jnxb7v6jb48wck0w@digimonkey.com> <20060816151444.yc5xuiao9yysggso@digimonkey.com> <3a2de0cd0608161419j64b1b321j1360157740b2e0bf@mail.gmail.com> Message-ID: <20060816164723.eqpn58tzqa04sggk@digimonkey.com> Check it out... I got it working: [ worker ] class PingWorker < BackgrounDRb::Rails attr_accessor :result def do_work(args) @result = IO.popen("ping -n 10 www.google.com") end end [ controller ] def ping_task session[:job_key] = MiddleMan.new_worker(:class => :ping_worker) end def ping_response if request.xhr? msg = MiddleMan.get_worker(session[:job_key]).result.gets render :update do |page| if msg.nil? MiddleMan.delete_worker(session[:job_key]) # ??? need some way to stop the PeriodicalExecuter. else page.insert_html :bottom, 'ping_result', msg+'
' end end else redirect_to :action => 'index' end end [ view ]
<%= periodically_call_remote(:url => {:action => :ping_response}, :frequency => 1) -%> Now if I can just figure out a way to stop the PeriodicalExecuter... [mp] Quoting Charles Brian Quinn : > We're working on a super cool new tool to help automate capistrano and > rake deployment task running on remote servers, and we do something > similiar to this using backgrounDRb (thanks Ezra!). > > It is based off our RailsDay 2006 entry: > http://heartbeat.highgroove.com/ -- enough with the bragging, here is > how we do it: > > your worker now needs to have an @output class variable (instead of > progress). > > in your worker, you can run the task one of two ways which might or > might not work: > > # you can use Kernel.system to make the call which I don't > know how you get output > if not Kernel.system("ping google) > errors.add_to_base(" your error here ") # this is > technically in a model hence the errors obj > raise > end > > # or: > cmd_to_run = "ping google" > > stdin, stdout, stderr = Open3.popen3(cmd_to_run) > > s_stderr = stderr.read.to_s > s_stdout = stdout.read.to_s > > # if you'd like to see it > logger.info "stdout: #{s_stdout}" > logger.info "stderr: #{s_stderr}" > > if s_stderr.empty? && s_stdout.starts_with?("error stuff here") > return true > else > errors.add_to_base("error msg here") > return false > end > > But, as for setting your @output, well, you'd need to run inside a > loop or perhaps even in another thread within the bg worker thread. > We don't need to do this because we're executing our task using ssh > and we have an open channel and just do @output << in the loop as it > runs. You may not be able to use the popen3 calls above, to be honest > -- the read pretty much kills that idea. Our worker method that > appends output looks like: > > Net::SSH.start( host, > :username => username, > :password => password, > :port => port ) do |session| > session.open_channel do |channel| > > channel.on_data do |ch, data| > @output << "#{data}" > end > > channel.on_extended_data do |ch, type, data| > @output << "#{data}" > end > > channel.exec( "ping google\n" ) > end > session.loop > end > > Maybe you can find a simliar asynchronous call for executing methods, > that updates output as it runs. > > Now, in your controller: > > the method, let's say execute: > > def execute > session[:job_key] = Middleman.... # call your worker > end > > and for the view we used rjs to update a page (a lightbox actually): > >
> Connecting to Server... >
> > execute.rjs: > > page << "showBG();" > page << "showIbox('#{url_for(:action => 'output', :id => > @task)}','',parseQuery('width=760&height=400'))" > page << "output = new > Ajax.PeriodicalUpdater('task_output','#{url_for(:action => > 'update_output', :id=> @task.id)}',2);" > > back to your controller, it can be as simple as: > > def update_output > @job = MiddleMan.get_worker(session[:job_key]) > render :inline => '<%= simple_format(@job.output) %>' > end > > The hard part will be appending @output as it's running. I know I > didn't answer the @output side, but hopefully helped with the > backgroundrb worker side. > > cheers and good luck, let us know how it goes. > > On 8/16/06, mattp at digimonkey.com wrote: >> Dunno if anyone saw the short question at the end of my last thread, >> so i'm reposting in a thread with the appropriate subject: >> >> Here's what I need to do -- >> >> Run a system-level command like 'ping -t www.google.com' and have it >> periodically update a
with the command's ouput. Is this possible? >> >> (the trick here is that I want *periodic* updates of the div... i want >> to see incremental output as 'ping' is running, just like if I were >> looking at console...) >> _______________________________________________ >> 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 From ezmobius at gmail.com Wed Aug 16 19:02:28 2006 From: ezmobius at gmail.com (Ezra Zygmuntowicz) Date: Wed, 16 Aug 2006 16:02:28 -0700 Subject: [Backgroundrb-devel] "tailing" a running system command? In-Reply-To: <20060816164723.eqpn58tzqa04sggk@digimonkey.com> References: <4F966DB6-838C-4E83-9B9B-AF4C63299963@gmail.com> <20060816122506.1w2qkrus7k7ocgck@digimonkey.com> <28FB7167-3BE4-4E8D-8E27-F7B50FBAB7B0@gmail.com> <20060816124803.jnxb7v6jb48wck0w@digimonkey.com> <20060816151444.yc5xuiao9yysggso@digimonkey.com> <3a2de0cd0608161419j64b1b321j1360157740b2e0bf@mail.gmail.com> <20060816164723.eqpn58tzqa04sggk@digimonkey.com> Message-ID: <5679F401-7AA7-4D55-B133-820EA0FA3069@brainspl.at> Very cool! I finally figured out how to stop a periodically_call_remote via rjs or js. Do it like this, in the view where you render your periodic call: <%= periodically_call_remote(:url => {:action => 'update_results'}, :frequency => 5, :condition => "stop_polling == false") %> Stop Polling #Or if you need to tell it to stop from the controller via rjs: def stop_polling render :update { |p| p.assign 'stop_polling', true } end And thats it, the periodic call will stop polling once the js variable stop_polling is set to true. Of course you could also just set it to true in the view but it depends on where you get the info that tells you to stop polling. Cheers- -Ezra On Aug 16, 2006, at 2:47 PM, mattp at digimonkey.com wrote: > Check it out... I got it working: > > [ worker ] > class PingWorker < BackgrounDRb::Rails > attr_accessor :result > > def do_work(args) > @result = IO.popen("ping -n 10 www.google.com") > end > end > > [ controller ] > def ping_task > session[:job_key] = MiddleMan.new_worker(:class => :ping_worker) > end > > def ping_response > if request.xhr? > msg = MiddleMan.get_worker(session[:job_key]).result.gets > render :update do |page| > if msg.nil? > MiddleMan.delete_worker(session[:job_key]) > # ??? need some way to stop the PeriodicalExecuter. > else > page.insert_html :bottom, 'ping_result', msg+'
' > end > end > else > redirect_to :action => 'index' > end > end > > [ view ] >
> <%= periodically_call_remote(:url => {:action => :ping_response}, > :frequency => 1) -%> > > > Now if I can just figure out a way to stop the PeriodicalExecuter... > > [mp] > > Quoting Charles Brian Quinn : > >> We're working on a super cool new tool to help automate capistrano >> and >> rake deployment task running on remote servers, and we do something >> similiar to this using backgrounDRb (thanks Ezra!). >> >> It is based off our RailsDay 2006 entry: >> http://heartbeat.highgroove.com/ -- enough with the bragging, here is >> how we do it: >> >> your worker now needs to have an @output class variable (instead of >> progress). >> >> in your worker, you can run the task one of two ways which might or >> might not work: >> >> # you can use Kernel.system to make the call which I don't >> know how you get output >> if not Kernel.system("ping google) >> errors.add_to_base(" your error here ") # this is >> technically in a model hence the errors obj >> raise >> end >> >> # or: >> cmd_to_run = "ping google" >> >> stdin, stdout, stderr = Open3.popen3(cmd_to_run) >> >> s_stderr = stderr.read.to_s >> s_stdout = stdout.read.to_s >> >> # if you'd like to see it >> logger.info "stdout: #{s_stdout}" >> logger.info "stderr: #{s_stderr}" >> >> if s_stderr.empty? && s_stdout.starts_with?("error stuff >> here") >> return true >> else >> errors.add_to_base("error msg here") >> return false >> end >> >> But, as for setting your @output, well, you'd need to run inside a >> loop or perhaps even in another thread within the bg worker thread. >> We don't need to do this because we're executing our task using ssh >> and we have an open channel and just do @output << in the loop as it >> runs. You may not be able to use the popen3 calls above, to be >> honest >> -- the read pretty much kills that idea. Our worker method that >> appends output looks like: >> >> Net::SSH.start( host, >> :username => username, >> :password => password, >> :port => port ) do |session| >> session.open_channel do |channel| >> >> channel.on_data do |ch, data| >> @output << "#{data}" >> end >> >> channel.on_extended_data do |ch, type, data| >> @output << "#{data}" >> end >> >> channel.exec( "ping google\n" ) >> end >> session.loop >> end >> >> Maybe you can find a simliar asynchronous call for executing methods, >> that updates output as it runs. >> >> Now, in your controller: >> >> the method, let's say execute: >> >> def execute >> session[:job_key] = Middleman.... # call your worker >> end >> >> and for the view we used rjs to update a page (a lightbox actually): >> >>
>> Connecting to Server... >>
>> >> execute.rjs: >> >> page << "showBG();" >> page << "showIbox('#{url_for(:action => 'output', :id => >> @task)}','',parseQuery('width=760&height=400'))" >> page << "output = new >> Ajax.PeriodicalUpdater('task_output','#{url_for(:action => >> 'update_output', :id=> @task.id)}',2);" >> >> back to your controller, it can be as simple as: >> >> def update_output >> @job = MiddleMan.get_worker(session[:job_key]) >> render :inline => '<%= simple_format(@job.output) %>' >> end >> >> The hard part will be appending @output as it's running. I know I >> didn't answer the @output side, but hopefully helped with the >> backgroundrb worker side. >> >> cheers and good luck, let us know how it goes. >> >> On 8/16/06, mattp at digimonkey.com wrote: >>> Dunno if anyone saw the short question at the end of my last thread, >>> so i'm reposting in a thread with the appropriate subject: >>> >>> Here's what I need to do -- >>> >>> Run a system-level command like 'ping -t www.google.com' and have it >>> periodically update a
with the command's ouput. Is this >>> possible? >>> >>> (the trick here is that I want *periodic* updates of the div... i >>> want >>> to see incremental output as 'ping' is running, just like if I were >>> looking at console...) >>> _______________________________________________ >>> 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 > > > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel > From mattp at digimonkey.com Wed Aug 16 19:15:34 2006 From: mattp at digimonkey.com (mattp at digimonkey.com) Date: Wed, 16 Aug 2006 18:15:34 -0500 Subject: [Backgroundrb-devel] "tailing" a running system command? In-Reply-To: <5679F401-7AA7-4D55-B133-820EA0FA3069@brainspl.at> References: <4F966DB6-838C-4E83-9B9B-AF4C63299963@gmail.com> <20060816122506.1w2qkrus7k7ocgck@digimonkey.com> <28FB7167-3BE4-4E8D-8E27-F7B50FBAB7B0@gmail.com> <20060816124803.jnxb7v6jb48wck0w@digimonkey.com> <20060816151444.yc5xuiao9yysggso@digimonkey.com> <3a2de0cd0608161419j64b1b321j1360157740b2e0bf@mail.gmail.com> <20060816164723.eqpn58tzqa04sggk@digimonkey.com> <5679F401-7AA7-4D55-B133-820EA0FA3069@brainspl.at> Message-ID: <20060816181534.02z5o6bo7s0kw08w@digimonkey.com> Nice. Based on your suggestion, I also found a simpler way (for me at least). [controller] def ping_response if request.xhr? msg = MiddleMan.get_worker(session[:job_key]).result.gets render :update do |page| if msg.nil? MiddleMan.delete_worker(session[:job_key]) page.remove('spinner') page.call('stop_xhr') # <=== LOOK HERE! THIS IS THE FANCY BIT!! else page.insert_html :bottom, 'ping_result', msg+'
' end end else redirect_to :action => 'index' end end [view] <%= periodically_call_remote(:url => {:action => :ping_response}, :frequency => 0.5, :condition => "stop_polling == false" ) -%> Quoting Ezra Zygmuntowicz : > Very cool! I finally figured out how to stop a > periodically_call_remote via rjs or js. Do it like this, in the view > where you render your periodic call: > > > > <%= periodically_call_remote(:url => {:action => 'update_results'}, > :frequency => 5, > :condition => "stop_polling == false") %> > > Stop Polling > > > #Or if you need to tell it to stop from the controller via rjs: > > def stop_polling > render :update { |p| p.assign 'stop_polling', true } > end > > > > And thats it, the periodic call will stop polling once the js variable > stop_polling is set to true. Of course you could also just set it to > true in the view but it depends on where you get the info that tells > you to stop polling. > > > Cheers- > -Ezra > > > On Aug 16, 2006, at 2:47 PM, mattp at digimonkey.com wrote: > >> Check it out... I got it working: >> >> [ worker ] >> class PingWorker < BackgrounDRb::Rails >> attr_accessor :result >> >> def do_work(args) >> @result = IO.popen("ping -n 10 www.google.com") >> end >> end >> >> [ controller ] >> def ping_task >> session[:job_key] = MiddleMan.new_worker(:class => :ping_worker) >> end >> >> def ping_response >> if request.xhr? >> msg = MiddleMan.get_worker(session[:job_key]).result.gets >> render :update do |page| >> if msg.nil? >> MiddleMan.delete_worker(session[:job_key]) >> # ??? need some way to stop the PeriodicalExecuter. >> else >> page.insert_html :bottom, 'ping_result', msg+'
' >> end >> end >> else >> redirect_to :action => 'index' >> end >> end >> >> [ view ] >>
>> <%= periodically_call_remote(:url => {:action => :ping_response}, >> :frequency => 1) -%> >> >> >> Now if I can just figure out a way to stop the PeriodicalExecuter... >> >> [mp] >> >> Quoting Charles Brian Quinn : >> >>> We're working on a super cool new tool to help automate capistrano and >>> rake deployment task running on remote servers, and we do something >>> similiar to this using backgrounDRb (thanks Ezra!). >>> >>> It is based off our RailsDay 2006 entry: >>> http://heartbeat.highgroove.com/ -- enough with the bragging, here is >>> how we do it: >>> >>> your worker now needs to have an @output class variable (instead of >>> progress). >>> >>> in your worker, you can run the task one of two ways which might or >>> might not work: >>> >>> # you can use Kernel.system to make the call which I don't >>> know how you get output >>> if not Kernel.system("ping google) >>> errors.add_to_base(" your error here ") # this is >>> technically in a model hence the errors obj >>> raise >>> end >>> >>> # or: >>> cmd_to_run = "ping google" >>> >>> stdin, stdout, stderr = Open3.popen3(cmd_to_run) >>> >>> s_stderr = stderr.read.to_s >>> s_stdout = stdout.read.to_s >>> >>> # if you'd like to see it >>> logger.info "stdout: #{s_stdout}" >>> logger.info "stderr: #{s_stderr}" >>> >>> if s_stderr.empty? && s_stdout.starts_with?("error stuff here") >>> return true >>> else >>> errors.add_to_base("error msg here") >>> return false >>> end >>> >>> But, as for setting your @output, well, you'd need to run inside a >>> loop or perhaps even in another thread within the bg worker thread. >>> We don't need to do this because we're executing our task using ssh >>> and we have an open channel and just do @output << in the loop as it >>> runs. You may not be able to use the popen3 calls above, to be honest >>> -- the read pretty much kills that idea. Our worker method that >>> appends output looks like: >>> >>> Net::SSH.start( host, >>> :username => username, >>> :password => password, >>> :port => port ) do |session| >>> session.open_channel do |channel| >>> >>> channel.on_data do |ch, data| >>> @output << "#{data}" >>> end >>> >>> channel.on_extended_data do |ch, type, data| >>> @output << "#{data}" >>> end >>> >>> channel.exec( "ping google\n" ) >>> end >>> session.loop >>> end >>> >>> Maybe you can find a simliar asynchronous call for executing methods, >>> that updates output as it runs. >>> >>> Now, in your controller: >>> >>> the method, let's say execute: >>> >>> def execute >>> session[:job_key] = Middleman.... # call your worker >>> end >>> >>> and for the view we used rjs to update a page (a lightbox actually): >>> >>>
>>> Connecting to Server... >>>
>>> >>> execute.rjs: >>> >>> page << "showBG();" >>> page << "showIbox('#{url_for(:action => 'output', :id => >>> @task)}','',parseQuery('width=760&height=400'))" >>> page << "output = new >>> Ajax.PeriodicalUpdater('task_output','#{url_for(:action => >>> 'update_output', :id=> @task.id)}',2);" >>> >>> back to your controller, it can be as simple as: >>> >>> def update_output >>> @job = MiddleMan.get_worker(session[:job_key]) >>> render :inline => '<%= simple_format(@job.output) %>' >>> end >>> >>> The hard part will be appending @output as it's running. I know I >>> didn't answer the @output side, but hopefully helped with the >>> backgroundrb worker side. >>> >>> cheers and good luck, let us know how it goes. >>> >>> On 8/16/06, mattp at digimonkey.com wrote: >>>> Dunno if anyone saw the short question at the end of my last thread, >>>> so i'm reposting in a thread with the appropriate subject: >>>> >>>> Here's what I need to do -- >>>> >>>> Run a system-level command like 'ping -t www.google.com' and have it >>>> periodically update a
with the command's ouput. Is this possible? >>>> >>>> (the trick here is that I want *periodic* updates of the div... i want >>>> to see incremental output as 'ping' is running, just like if I were >>>> looking at console...) >>>> _______________________________________________ >>>> 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 >> >> >> _______________________________________________ >> Backgroundrb-devel mailing list >> Backgroundrb-devel at rubyforge.org >> http://rubyforge.org/mailman/listinfo/backgroundrb-devel >> From mark at martianrover.com Thu Aug 17 17:15:54 2006 From: mark at martianrover.com (P. Mark Anderson) Date: Thu, 17 Aug 2006 14:15:54 -0700 Subject: [Backgroundrb-devel] Worker pool worker for page scanners: lost connection to mysql Message-ID: <66578419-55AF-46D1-B99D-A04DDDA649B8@martianrover.com> Hello, I want to scan many URLs simultaneously with a new scanner worker for each URL, but I keep getting Mysql::Error: Lost connection to MySQL. Yes, allow_concurrency=false. Each scanner thread needs access to my ActiveRecord models to store discovered feeds and whatnot. There is a DB table called page_scans that acts as a big queue holding URLs waiting to be scanned. It would be nice to run a worker that spawns up to 10 scanner workers at a time to chip away at the queue, but first I need to figure out what kinds of problems kill the mysql connection in a worker. Any thoughts are much appreciated! Mark From ezmobius at gmail.com Thu Aug 17 18:24:06 2006 From: ezmobius at gmail.com (Ezra Zygmuntowicz) Date: Thu, 17 Aug 2006 15:24:06 -0700 Subject: [Backgroundrb-devel] Worker pool worker for page scanners: lost connection to mysql In-Reply-To: <66578419-55AF-46D1-B99D-A04DDDA649B8@martianrover.com> References: <66578419-55AF-46D1-B99D-A04DDDA649B8@martianrover.com> Message-ID: On Aug 17, 2006, at 2:15 PM, P. Mark Anderson wrote: > Hello, > > I want to scan many URLs simultaneously with a new scanner worker for > each URL, but I keep getting Mysql::Error: Lost connection to MySQL. > Yes, allow_concurrency=false. > > Each scanner thread needs access to my ActiveRecord models to store > discovered feeds and whatnot. There is a DB table called page_scans > that acts as a big queue holding URLs waiting to be scanned. > > It would be nice to run a worker that spawns up to 10 scanner workers > at a time to chip away at the queue, but first I need to figure out > what kinds of problems kill the mysql connection in a worker. > > Any thoughts are much appreciated! > > Mark > > > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel Mark-- Have you tried it with allow_concurency = true? Stuff like this is hard because even though Active Record pretends like it is thread safe I don't really think it is. If it doesn't work with allow_concurrency = true then you might need to look at just using the mysql-ruby bindings directly and *gasp* writing some sql just for this worker. Cheers- -Ezra From bjohnson at contuitive.com Fri Aug 18 18:14:08 2006 From: bjohnson at contuitive.com (Ben Johnson) Date: Fri, 18 Aug 2006 17:14:08 -0500 Subject: [Backgroundrb-devel] Ezra....allow_concurrency = false? Message-ID: <135E4B51-50E0-433E-8706-22EB617ED845@contuitive.com> In a previous email you wrote this: Glad you're getting some use out of the plugin ;) ActiveRecord does have some issues with threading and concurrency that can sometimes cause that error you are seeing. Open up your script/backgroundrb/ start file and comment out the following line: ActiveRecord::Base.allow_concurrency = true Make sure you do that up in your main app script folder and not in the plugin. Well you can do it in the plugin as well to keep it consistent. Then you need to restart the drb server. Give this a shot and see if it gets rid of your problem. Also I am curious about using this plugin on textdrive. Did they give you an extra port number to run it on? If you run into problems with running the drb server on a port then let me know and I can show you how to use a unix domain socket file instead so you don't take up an extra port. You wrote that in response to getting rid of the MySQL server has gone away error. Why would you comment it out in the app and not in the start script? Wouldn't you want to comment it out in the plugin start script? Thank You, Ben Johnson E: bjohnson at contuitive.com O: 800-341-6826 M: 817-229-4258 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060818/aeeedef5/attachment.html From ezmobius at gmail.com Fri Aug 18 18:51:46 2006 From: ezmobius at gmail.com (Ezra Zygmuntowicz) Date: Fri, 18 Aug 2006 15:51:46 -0700 Subject: [Backgroundrb-devel] Ezra....allow_concurrency = false? In-Reply-To: <135E4B51-50E0-433E-8706-22EB617ED845@contuitive.com> References: <135E4B51-50E0-433E-8706-22EB617ED845@contuitive.com> Message-ID: On Aug 18, 2006, at 3:14 PM, Ben Johnson wrote: > In a previous email you wrote this: > > Glad you're getting some use out of the plugin ;) ActiveRecord does > have some issues with threading and concurrency that can sometimes > cause that error you are seeing. Open up your script/backgroundrb/ > start file and comment out the following line: > > ActiveRecord::Base.allow_concurrency = true > > Make sure you do that up in your main app script folder and not in > the plugin. Well you can do it in the plugin as well to keep it > consistent. Then you need to restart the drb server. Give this a shot > and see if it gets rid of your problem. Also I am curious about using > this plugin on textdrive. Did they give you an extra port number to > run it on? If you run into problems with running the drb server on a > port then let me know and I can show you how to use a unix domain > socket file instead so you don't take up an extra port. > > You wrote that in response to getting rid of the MySQL server has > gone away error. Why would you comment it out in the app and not in > the start script? Wouldn't you want to comment it out in the plugin > start script? > > Thank You, > Ben Johnson > E: bjohnson at contuitive.com > O: 800-341-6826 > M: 817-229-4258 When you run the rake backgroundrb:setup task it copies the start script up into your apps script directory. So you need to make the change up there. Or you can make the change in the plugin and then rerun the setup task if you like. Either way its the same thing. You need to make the changes to the start script that is in the script/ backgroundrb directory of your rails app in order for them to be used. Does that answer your question? -Ezra -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060818/4988b2ed/attachment.html From bjohnson at contuitive.com Fri Aug 18 21:20:11 2006 From: bjohnson at contuitive.com (Ben Johnson) Date: Fri, 18 Aug 2006 20:20:11 -0500 Subject: [Backgroundrb-devel] Impossible to get stable? Message-ID: <284E7D6B-A5E6-48D1-B912-D7CFFB23DD32@contuitive.com> I have concluded that it is impossible to get this background process stable. I am out of ideas and could really use some help. Here is what I have: 50 workers, just running an infinite loop that constantly calls save! on a model. Keep in mind this is just for testing purposes. I catch all exceptions and put them in the log. I am tried setting allow_concurrency to true and false. Neither of them is stable. For both true and false I have got the following errors: # Is it possible to make the process priority higher for backgroundrb? Thank You, Ben Johnson E: bjohnson at contuitive.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060819/7a2e6d1b/attachment.html From ezmobius at gmail.com Sun Aug 20 00:39:25 2006 From: ezmobius at gmail.com (Ezra Zygmuntowicz) Date: Sat, 19 Aug 2006 21:39:25 -0700 Subject: [Backgroundrb-devel] Impossible to get stable? In-Reply-To: <284E7D6B-A5E6-48D1-B912-D7CFFB23DD32@contuitive.com> References: <284E7D6B-A5E6-48D1-B912-D7CFFB23DD32@contuitive.com> Message-ID: <1FD6BA47-DD3A-4A1C-98FA-0E17BA8B391D@gmail.com> On Aug 18, 2006, at 6:20 PM, Ben Johnson wrote: > I have concluded that it is impossible to get this background > process stable. I am out of ideas and could really use some help. > > Here is what I have: > > 50 workers, just running an infinite loop that constantly calls > save! on a model. Keep in mind this is just for testing purposes. I > catch all exceptions and put them in the log. > > I am tried setting allow_concurrency to true and false. Neither of > them is stable. For both true and false I have got the following > errors: > > # exceeded; try restarting transaction: > > # gone away: > > What have you found to be most stable? Setting allow concurrency to > false and just putting a Mutex.synchronize object around all > database calls? Or setting it true? > > Thank You, > Ben Johnson > E: bjohnson at contuitive.com > O: 800-341-6826 > M: 817-229-4258 Hey Ben- I feel your pain. I have come to the conclusion that ActiveRecord is just not thread safe no matter what you do. My best suggestion is to use either dbi or mysql bindings directly in your workers. These are thread safe and while you would have to write some sql yourself, it would solve your issue. I get the feeling that railscore is not very interested in making rails thread safe at this point and pushing as many db connections in as many threads as you are doing is more the ActiveRecord can handle. I know its not what you want to hear but its the situation we have to deal with. -Ezra -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060819/d73ba4a7/attachment-0001.html From ezmobius at gmail.com Sun Aug 20 00:45:07 2006 From: ezmobius at gmail.com (Ezra Zygmuntowicz) Date: Sat, 19 Aug 2006 21:45:07 -0700 Subject: [Backgroundrb-devel] Setting the process priority? In-Reply-To: <8A7776BA-71E7-4A0F-9D79-23F07429083E@contuitive.com> References: <8A7776BA-71E7-4A0F-9D79-23F07429083E@contuitive.com> Message-ID: <7F5DF5EB-940D-4BE2-90CC-F99BC2C7E8F5@brainspl.at> On Aug 19, 2006, at 3:45 PM, Ben Johnson wrote: > Is it possible to make the process priority higher for backgroundrb? > > > Thank You, > Ben Johnson > E: bjohnson at contuitive.com > > > > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel Ben- You mean like the OS level? I think that would be totally dependent on what OS you are running. And I don't think it would be something you could do from within ruby. I think you would have to do it from within your OS. Well you could make some system calls to set the nice level i guess. Also in your case maybe you might want to consider running more then one bgdrb daemon. You could easily seperate the drb servers and run a certain amount of workers in one and more workers in another. This would require some hacking on your part but not too much. You could duplicate the code block in the plugin/lib/backgrondrb.rb file and rename the second one MiddleMan2 or whatever and change the port number. I may add this as an option in a future release. I am also playing with the idea of using Rinda TupleSpace to distribute the workers across multiple processes. This would allow for bigger jobs to be easily processed by multiple workers in their own processes. Let me know what you end up doing. -Ezra -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060819/b6604674/attachment.html From bjohnson at contuitive.com Sun Aug 20 03:27:09 2006 From: bjohnson at contuitive.com (Ben Johnson) Date: Sun, 20 Aug 2006 02:27:09 -0500 Subject: [Backgroundrb-devel] Impossible to get stable? In-Reply-To: <1FD6BA47-DD3A-4A1C-98FA-0E17BA8B391D@gmail.com> References: <284E7D6B-A5E6-48D1-B912-D7CFFB23DD32@contuitive.com> <1FD6BA47-DD3A-4A1C-98FA-0E17BA8B391D@gmail.com> Message-ID: <6E59ED5A-4BC2-409D-97E3-A4A2DE50A522@contuitive.com> Hi Ezra, Thanks a lot for your help. Can you clarify what dbi is or mysql bindings? I am not sure what you are talking about. Thanks again for your help. Thank You, Ben Johnson E: bjohnson at contuitive.com O: 800-341-6826 M: 817-229-4258 On Aug 19, 2006, at 11:39 PM, Ezra Zygmuntowicz wrote: > > On Aug 18, 2006, at 6:20 PM, Ben Johnson wrote: > >> I have concluded that it is impossible to get this background >> process stable. I am out of ideas and could really use some help. >> >> Here is what I have: >> >> 50 workers, just running an infinite loop that constantly calls >> save! on a model. Keep in mind this is just for testing purposes. >> I catch all exceptions and put them in the log. >> >> I am tried setting allow_concurrency to true and false. Neither of >> them is stable. For both true and false I have got the following >> errors: >> >> #> exceeded; try restarting transaction: >> >> #> gone away: >> >> What have you found to be most stable? Setting allow concurrency >> to false and just putting a Mutex.synchronize object around all >> database calls? Or setting it true? >> >> Thank You, >> Ben Johnson >> E: bjohnson at contuitive.com >> O: 800-341-6826 >> M: 817-229-4258 > > > Hey Ben- > > I feel your pain. I have come to the conclusion that ActiveRecord > is just not thread safe no matter what you do. My best suggestion > is to use either dbi or mysql bindings directly in your workers. > These are thread safe and while you would have to write some sql > yourself, it would solve your issue. I get the feeling that > railscore is not very interested in making rails thread safe at > this point and pushing as many db connections in as many threads as > you are doing is more the ActiveRecord can handle. > > I know its not what you want to hear but its the situation we have > to deal with. > > -Ezra -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060820/9251d721/attachment.html From info at siebert-wd.de Sun Aug 20 03:36:07 2006 From: info at siebert-wd.de (Michael Siebert) Date: Sun, 20 Aug 2006 09:36:07 +0200 Subject: [Backgroundrb-devel] Impossible to get stable? In-Reply-To: <6E59ED5A-4BC2-409D-97E3-A4A2DE50A522@contuitive.com> References: <284E7D6B-A5E6-48D1-B912-D7CFFB23DD32@contuitive.com> <1FD6BA47-DD3A-4A1C-98FA-0E17BA8B391D@gmail.com> <6E59ED5A-4BC2-409D-97E3-A4A2DE50A522@contuitive.com> Message-ID: <32b567370608200036x661aa9b1kcdfd58a53ab5d375@mail.gmail.com> dbi and mysql is the basic layer of database access. its just a way to connect to a db server and send a query. no modelous abstractions, no stuff around, just tailor your sql like back in (good) old php days. thats surely not the rails way and uncomfortable but it should give no errors (except that your db only can handle a certain amount of connections) 2006/8/20, Ben Johnson : > > Hi Ezra, > Thanks a lot for your help. Can you clarify what dbi is or mysql bindings? > I am not sure what you are talking about. > > Thanks again for your help. > > Thank You, > Ben Johnson > E: bjohnson at contuitive.com > O: 800-341-6826 > M: 817-229-4258 > > > > On Aug 19, 2006, at 11:39 PM, Ezra Zygmuntowicz wrote: > > > On Aug 18, 2006, at 6:20 PM, Ben Johnson wrote: > > I have concluded that it is impossible to get this background process > stable. I am out of ideas and could really use some help. > Here is what I have: > > 50 workers, just running an infinite loop that constantly calls save! on a > model. Keep in mind this is just for testing purposes. I catch all > exceptions and put them in the log. > > I am tried setting allow_concurrency to true and false. Neither of them is > stable. For both true and false I have got the following errors: > > # exceeded; try restarting transaction: > > # away: > > What have you found to be most stable? Setting allow concurrency to false > and just putting a Mutex.synchronize object around all database calls? Or > setting it true? > > Thank You, > Ben Johnson > E: bjohnson at contuitive.com > O: 800-341-6826 > M: 817-229-4258 > > > > Hey Ben- > > I feel your pain. I have come to the conclusion that ActiveRecord is just > not thread safe no matter what you do. My best suggestion is to use either > dbi or mysql bindings directly in your workers. These are thread safe and > while you would have to write some sql yourself, it would solve your issue. > I get the feeling that railscore is not very interested in making rails > thread safe at this point and pushing as many db connections in as many > threads as you are doing is more the ActiveRecord can handle. > > I know its not what you want to hear but its the situation we have to deal > with. > > -Ezra > > > > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel > > -- Michael Siebert www.siebert-wd.de - Gedanken lesen www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060820/ed5cf82a/attachment.html From eimorton at gmail.com Sun Aug 20 08:20:45 2006 From: eimorton at gmail.com (Erik Morton) Date: Sun, 20 Aug 2006 08:20:45 -0400 Subject: [Backgroundrb-devel] Impossible to get stable? In-Reply-To: <1FD6BA47-DD3A-4A1C-98FA-0E17BA8B391D@gmail.com> References: <284E7D6B-A5E6-48D1-B912-D7CFFB23DD32@contuitive.com> <1FD6BA47-DD3A-4A1C-98FA-0E17BA8B391D@gmail.com> Message-ID: <2D2D37F4-5FE5-4C96-9A3C-A69C64F8D3AA@gmail.com> I'm planning on using Backgroundrb to run background processes for a fairly large all-Rails application that is launching in two weeks. I've been getting a bit paranoid about how ActiveRecord would react with possibly as many as twenty workers chugging away at the same time on the same tables. I put together a dead-simple "test" and the results were, I think, very positive. (The OS is OSX 10.4.7) Setup: One worker class that queries a MySQL database (4.1.18) n times and then calls ActiveRecord::Base.connection.disconnect! and kill. The worker executes the "SHOW PROCESSLIST" query, which returns a list of active MySQL processes, and logs the number of active connections along with the to_s of the connection and the thread. The test script uses MiddleMan to instantiate 100 workers passing in the worker's number as the number (10, 11, 12...110) of times the worker should loop and query the database. I took this approach so that the workers would be closing connections while other threads had connections open. Goals: 1) verify that each Thread has his own connection. 2) verify that each worker can call disconnect! to close their own connection to free it up for other workers. Here's a snippet of the log file. worker number, ActiveRecord::Base.object_id, ActiveRecord::Base.connection.to_s, Thread.current.to_s, # of active MySQL connections 25, 3705192, #, #, 12 21, 3705192, #, #, 12 18, 3705192, #, #, 12 17, 3705192, #, #, 12 16, 3705192, #, #, 12 15, 3705192, #, #, 12 23, 3705192, #, #, 11 In this rather unscientific way I have positively confirmed (I think) that on Mac OSX 10.4.7, MySQL 4.1.18 and AR 1.14.4, each worker gets his own thread with his own connection, and can freely close his connection without adversely affecting any other thread. Any thoughts on this approach? I made one small change to swap out the SHOW PROCESS list query with MyModel.find :first and the results were the same -- each worker had his own thread with his own connection that he can close without affecting any other threads. Finally, I altered the start script to set allow concurrency to false, ran the test and not surprisingly all heck broke loose: 39, 3705192, #, #, 1 25, 3705192, #, #, 1 86, 3705192,#,#, 54, 3705192, #, #, 1 87, 3705192,#,#, Mysql::Error: MySQL server has gone away: SHOW PROCESSLIST; - (ActiveRecord::StatementInvalid) /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/ active_record/connection_adapters/abstract_adapter.rb:120:in `log' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/ active_record/connection_adapters/mysql_adapter.rb:184:in `execute' Different threads but the same connection and the first worker that closes his connection ruins the whole party. Are results like the above consistent with the intention of Backgroundrb? Is my approach was at least somewhat valid? Erik On Aug 20, 2006, at 12:39 AM, Ezra Zygmuntowicz wrote: > > On Aug 18, 2006, at 6:20 PM, Ben Johnson wrote: > >> I have concluded that it is impossible to get this background >> process stable. I am out of ideas and could really use some help. >> >> Here is what I have: >> >> 50 workers, just running an infinite loop that constantly calls >> save! on a model. Keep in mind this is just for testing purposes. >> I catch all exceptions and put them in the log. >> >> I am tried setting allow_concurrency to true and false. Neither of >> them is stable. For both true and false I have got the following >> errors: >> >> #> exceeded; try restarting transaction: >> >> #> gone away: >> >> What have you found to be most stable? Setting allow concurrency >> to false and just putting a Mutex.synchronize object around all >> database calls? Or setting it true? >> >> Thank You, >> Ben Johnson >> E: bjohnson at contuitive.com >> O: 800-341-6826 >> M: 817-229-4258 > > > Hey Ben- > > I feel your pain. I have come to the conclusion that ActiveRecord > is just not thread safe no matter what you do. My best suggestion > is to use either dbi or mysql bindings directly in your workers. > These are thread safe and while you would have to write some sql > yourself, it would solve your issue. I get the feeling that > railscore is not very interested in making rails thread safe at > this point and pushing as many db connections in as many threads as > you are doing is more the ActiveRecord can handle. > > I know its not what you want to hear but its the situation we have > to deal with. > > -Ezra > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel From ezmobius at gmail.com Sun Aug 20 14:41:49 2006 From: ezmobius at gmail.com (Ezra Zygmuntowicz) Date: Sun, 20 Aug 2006 11:41:49 -0700 Subject: [Backgroundrb-devel] Impossible to get stable? In-Reply-To: <2D2D37F4-5FE5-4C96-9A3C-A69C64F8D3AA@gmail.com> References: <284E7D6B-A5E6-48D1-B912-D7CFFB23DD32@contuitive.com> <1FD6BA47-DD3A-4A1C-98FA-0E17BA8B391D@gmail.com> <2D2D37F4-5FE5-4C96-9A3C-A69C64F8D3AA@gmail.com> Message-ID: <8715E247-7DF9-46FE-8AC3-43BCA608A291@gmail.com> Hey Eric- Yeah I think your approach is valid. Would you mind sending me the code you used for this experiment? I would like to run some tests myself. I will add some unit tests to try and see what the upper limits of threaded AR usage is. Thanks- -Ezra On Aug 20, 2006, at 5:20 AM, Erik Morton wrote: > I'm planning on using Backgroundrb to run background processes for a > fairly large all-Rails application that is launching in two weeks. > I've been getting a bit paranoid about how ActiveRecord would react > with possibly as many as twenty workers chugging away at the same > time on the same tables. I put together a dead-simple "test" and the > results were, I think, very positive. (The OS is OSX 10.4.7) > > Setup: One worker class that queries a MySQL database (4.1.18) n > times and then calls ActiveRecord::Base.connection.disconnect! and > kill. The worker executes the "SHOW PROCESSLIST" query, which returns > a list of active MySQL processes, and logs the number of active > connections along with the to_s of the connection and the thread. > > The test script uses MiddleMan to instantiate 100 workers passing in > the worker's number as the number (10, 11, 12...110) of times the > worker should loop and query the database. I took this approach so > that the workers would be closing connections while other threads had > connections open. > > Goals: 1) verify that each Thread has his own connection. 2) verify > that each worker can call disconnect! to close their own connection > to free it up for other workers. > > Here's a snippet of the log file. > > worker number, ActiveRecord::Base.object_id, > ActiveRecord::Base.connection.to_s, Thread.current.to_s, # of active > MySQL connections > 25, 3705192, # 0x277ba04>, #, 12 > 21, 3705192, # 0x277a730>, #, 12 > 18, 3705192, # 0x26c86e8>, #, 12 > 17, 3705192, # 0x26d61d0>, #, 12 > 16, 3705192, # 0x26e06d0>, #, 12 > 15, 3705192, # 0x26e7098>, #, 12 > 23, 3705192, # 0x2784f8c>, #, 11 > > In this rather unscientific way I have positively confirmed (I think) > that on Mac OSX 10.4.7, MySQL 4.1.18 and AR 1.14.4, each worker gets > his own thread with his own connection, and can freely close his > connection without adversely affecting any other thread. Any thoughts > on this approach? > > I made one small change to swap out the SHOW PROCESS list query with > MyModel.find :first and the results were the same -- each worker had > his own thread with his own connection that he can close without > affecting any other threads. > > Finally, I altered the start script to set allow concurrency to > false, ran the test and not surprisingly all heck broke loose: > > 39, 3705192, # 0x26fdca8>, #, 1 > 25, 3705192, # 0x26fdca8>, #, 1 > 86, 3705192,# 0x26fdca8>,#, > 54, 3705192, # 0x26fdca8>, #, 1 > 87, 3705192,# 0x26fdca8>,#, > Mysql::Error: MySQL server has gone away: SHOW PROCESSLIST; - > (ActiveRecord::StatementInvalid) > /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/ > active_record/connection_adapters/abstract_adapter.rb:120:in `log' > /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/ > active_record/connection_adapters/mysql_adapter.rb:184:in `execute' > > Different threads but the same connection and the first worker that > closes his connection ruins the whole party. > > Are results like the above consistent with the intention of > Backgroundrb? Is my approach was at least somewhat valid? > > Erik > > On Aug 20, 2006, at 12:39 AM, Ezra Zygmuntowicz wrote: > >> >> On Aug 18, 2006, at 6:20 PM, Ben Johnson wrote: >> >>> I have concluded that it is impossible to get this background >>> process stable. I am out of ideas and could really use some help. >>> >>> Here is what I have: >>> >>> 50 workers, just running an infinite loop that constantly calls >>> save! on a model. Keep in mind this is just for testing purposes. >>> I catch all exceptions and put them in the log. >>> >>> I am tried setting allow_concurrency to true and false. Neither of >>> them is stable. For both true and false I have got the following >>> errors: >>> >>> #>> exceeded; try restarting transaction: >>> >>> #>> gone away: >>> >>> What have you found to be most stable? Setting allow concurrency >>> to false and just putting a Mutex.synchronize object around all >>> database calls? Or setting it true? >>> >>> Thank You, >>> Ben Johnson >>> E: bjohnson at contuitive.com >>> O: 800-341-6826 >>> M: 817-229-4258 >> >> >> Hey Ben- >> >> I feel your pain. I have come to the conclusion that ActiveRecord >> is just not thread safe no matter what you do. My best suggestion >> is to use either dbi or mysql bindings directly in your workers. >> These are thread safe and while you would have to write some sql >> yourself, it would solve your issue. I get the feeling that >> railscore is not very interested in making rails thread safe at >> this point and pushing as many db connections in as many threads as >> you are doing is more the ActiveRecord can handle. >> >> I know its not what you want to hear but its the situation we have >> to deal with. >> >> -Ezra >> _______________________________________________ >> Backgroundrb-devel mailing list >> Backgroundrb-devel at rubyforge.org >> http://rubyforge.org/mailman/listinfo/backgroundrb-devel > > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel > From lapomme00 at gmail.com Sun Aug 20 22:37:46 2006 From: lapomme00 at gmail.com (Brett Walker) Date: Mon, 21 Aug 2006 10:37:46 +0800 Subject: [Backgroundrb-devel] Recommended start order when deploying with Capistrano... Message-ID: When deploying with Capistrano, what's the recommended start ordering for BackgrounDRb? mongrel_stop backgroundrb_restart mongrel_start - or - mongrel_restart backgroundrb_restart - or - backgroundrb_restart mongrel_restart Or does it matter? Cheers, Brett From ezmobius at gmail.com Sun Aug 20 23:02:15 2006 From: ezmobius at gmail.com (Ezra Zygmuntowicz) Date: Sun, 20 Aug 2006 20:02:15 -0700 Subject: [Backgroundrb-devel] Recommended start order when deploying with Capistrano... In-Reply-To: References: Message-ID: <83A84CD6-9009-4725-8AB1-6AD30C9CC7FF@brainspl.at> On Aug 20, 2006, at 7:37 PM, Brett Walker wrote: > When deploying with Capistrano, what's the recommended start ordering > for BackgrounDRb? > > mongrel_stop > backgroundrb_restart > mongrel_start > > - or - > > mongrel_restart > backgroundrb_restart > > - or - > > backgroundrb_restart > mongrel_restart > > > Or does it matter? > > Cheers, > Brett Brett- You need to start the drb server before the mongrels start or restart. The drb server needs to be running when rails boots up so the MiddleMan can conect to the drb server -Ezra From gethemant at gmail.com Mon Aug 21 01:24:47 2006 From: gethemant at gmail.com (hemant) Date: Mon, 21 Aug 2006 10:54:47 +0530 Subject: [Backgroundrb-devel] strange problem with system call Message-ID: Hi, I am using backgroundrb to create a automated system of typo blogs.So, users can create new typo applications using web interface and all that jazz. Now..its working perfectly except one minor glitch. Since latest version of typo has a command called "typo", i simply use that command to install new typo app.And it works. def do_work(args) DIR = "/home/foobar/public_html" username = args blog_name = username + "_blog" # creation part works flawlessly so lets skip that. # there is a problem while stopping it. if (Dir.chdir(DIR)) == 0 current_dir = `pwd` @logger.debug("Current directory is #{current_dir}") stop_command = "typo stop "+ blog_name debug_stuff = `#{stop_command}` #line no 33 @logger.debug("### #{debug_stuff}") else @logger.debug("### Error changing directory") end end Now let me assure that, args has correct username, because starting of blog,migrating from sqlite to mysql works perfectly using this worker thread.The only glitch is, in line # 33, "typo stop " doesn't work.I have tried system also.system returns true, so typo should be stopped.But when i do "ps aux|grep foobar" , it isn't ,process is still there. When i tried `command`. All i got in debug_stuff variable is a empty string.However, when i try same stuff from irb, it works as expected and typo stopped.Now..again let me assure that, the worker thread IS getting CALLED. I have tried various stuff.But since, I am simply not able to debug, where the heck problem is, I am lost. I was told that, system or `command` both wait for the command to finish execution to resume normal execution.But for me it SEEMS that the call to "typo stop #{blog_name}" returns immediately. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060821/84d21e30/attachment.html From me at seebq.com Mon Aug 21 11:29:21 2006 From: me at seebq.com (Charles Brian Quinn) Date: Mon, 21 Aug 2006 11:29:21 -0400 Subject: [Backgroundrb-devel] strange problem with system call In-Reply-To: References: Message-ID: <3a2de0cd0608210829l317170f3j4e71ca44fd18ec6f@mail.gmail.com> Many times those calls to start/stop scripts get backgrounded, so it could actually be returning instantly. You could try wrapping it, or go check what typo stop is actually doing and make sure there's no "blah blah &" in the script. You could also try using popen and popen3 processes instead of the `command` backticks. I find those hard to debug as you don't know what's going on when they run. This will allow you to see stdin, stderr, and stdout on the process. Sample: cmd_to_run = "typo stop" stdin, stdout, stderr = Open3.popen3(cmd_to_run) s_stderr = stderr.read.to_s s_stdout = stdout.read.to_s # if you'd like to see it logger.info "stdout: #{s_stdout}" logger.info "stderr: #{s_stderr}" if s_stderr.empty? && s_stdout.starts_with?("error stuff here") return true else errors.add_to_base("error msg here") return false end hope that helps! On 8/21/06, hemant wrote: > Hi, > > I am using backgroundrb to create a automated system of typo blogs.So, users > can create new typo applications using web interface and all that jazz. > > Now..its working perfectly except one minor glitch. Since latest version of > typo has a command called "typo", i simply use that command to install new > typo app.And it works. > > def do_work(args) > DIR = "/home/foobar/public_html" > username = args > blog_name = username + "_blog" > # creation part works flawlessly so lets skip that. > # there is a problem while stopping it. > if (Dir.chdir(DIR)) == 0 > current_dir = `pwd` > @logger.debug("Current directory is #{current_dir}") > stop_command = "typo stop "+ blog_name > debug_stuff = `#{stop_command}` > #line no 33 > @logger.debug("### #{debug_stuff}") > else > @logger.debug("### Error changing directory") > end > end > Now let me assure that, args has correct username, because starting of > blog,migrating from sqlite to mysql works perfectly using this worker > thread.The only glitch is, in line # 33, "typo stop " doesn't work.I have > tried system also.system returns true, so typo should be stopped.But when i > do "ps aux|grep foobar" , it isn't ,process is still there. > > When i tried `command`. All i got in debug_stuff variable is a empty > string.However, when i try same stuff from irb, it works as expected and > typo stopped.Now..again let me assure that, the worker thread IS getting > CALLED. > > I have tried various stuff.But since, I am simply not able to debug, where > the heck problem is, I am lost. I was told that, system or `command` both > wait for the command to finish execution to resume normal execution.But for > me it SEEMS that the call to "typo stop #{blog_name}" returns immediately. > > > > > _______________________________________________ > 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 From ezmobius at gmail.com Mon Aug 21 11:38:34 2006 From: ezmobius at gmail.com (Ezra Zygmuntowicz) Date: Mon, 21 Aug 2006 08:38:34 -0700 Subject: [Backgroundrb-devel] strange problem with system call In-Reply-To: <3a2de0cd0608210829l317170f3j4e71ca44fd18ec6f@mail.gmail.com> References: <3a2de0cd0608210829l317170f3j4e71ca44fd18ec6f@mail.gmail.com> Message-ID: <7AD41E49-92B6-4615-85B7-593615BC26FB@gmail.com> Yeah Charles has the right idea. One other way to do what you want would be to kill the process directly by running pid = `ps axww | grep -v grep | grep typo` # or whatever the process is called? then get the pid out of that text and do a kill -9 on it. But I think you are probably better off with a popen solution. I am going to be redoing the start scripts to use the daemons gem which might fix this problem. -Ezra On Aug 21, 2006, at 8:29 AM, Charles Brian Quinn wrote: > Many times those calls to start/stop scripts get backgrounded, so it > could actually be returning instantly. You could try wrapping it, or > go check what typo stop is actually doing and make sure there's no > "blah blah &" in the script. > > You could also try using popen and popen3 processes instead of the > `command` backticks. I find those hard to debug as you don't know > what's going on when they run. > > This will allow you to see stdin, stderr, and stdout on the > process. Sample: > > cmd_to_run = "typo stop" > > stdin, stdout, stderr = Open3.popen3(cmd_to_run) > > s_stderr = stderr.read.to_s > s_stdout = stdout.read.to_s > > # if you'd like to see it > logger.info "stdout: #{s_stdout}" > logger.info "stderr: #{s_stderr}" > > if s_stderr.empty? && s_stdout.starts_with?("error stuff here") > return true > else > errors.add_to_base("error msg here") > return false > end > > hope that helps! > > On 8/21/06, hemant wrote: >> Hi, >> >> I am using backgroundrb to create a automated system of typo >> blogs.So, users >> can create new typo applications using web interface and all that >> jazz. >> >> Now..its working perfectly except one minor glitch. Since latest >> version of >> typo has a command called "typo", i simply use that command to >> install new >> typo app.And it works. >> >> def do_work(args) >> DIR = "/home/foobar/public_html" >> username = args >> blog_name = username + "_blog" >> # creation part works flawlessly so lets skip that. >> # there is a problem while stopping it. >> if (Dir.chdir(DIR)) == 0 >> current_dir = `pwd` >> @logger.debug("Current directory is #{current_dir}") >> stop_command = "typo stop "+ blog_name >> debug_stuff = `#{stop_command}` >> #line no 33 >> @logger.debug("### #{debug_stuff}") >> else >> @logger.debug("### Error changing directory") >> end >> end >> Now let me assure that, args has correct username, because >> starting of >> blog,migrating from sqlite to mysql works perfectly using this worker >> thread.The only glitch is, in line # 33, "typo stop " doesn't >> work.I have >> tried system also.system returns true, so typo should be >> stopped.But when i >> do "ps aux|grep foobar" , it isn't ,process is still there. >> >> When i tried `command`. All i got in debug_stuff variable is a empty >> string.However, when i try same stuff from irb, it works as >> expected and >> typo stopped.Now..again let me assure that, the worker thread IS >> getting >> CALLED. >> >> I have tried various stuff.But since, I am simply not able to >> debug, where >> the heck problem is, I am lost. I was told that, system or >> `command` both >> wait for the command to finish execution to resume normal >> execution.But for >> me it SEEMS that the call to "typo stop #{blog_name}" returns >> immediately. >> >> >> >> >> _______________________________________________ >> 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 > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel From gethemant at gmail.com Mon Aug 21 17:00:06 2006 From: gethemant at gmail.com (hemant) Date: Tue, 22 Aug 2006 02:30:06 +0530 Subject: [Backgroundrb-devel] strange problem with system call In-Reply-To: <7AD41E49-92B6-4615-85B7-593615BC26FB@gmail.com> References: <3a2de0cd0608210829l317170f3j4e71ca44fd18ec6f@mail.gmail.com> <7AD41E49-92B6-4615-85B7-593615BC26FB@gmail.com> Message-ID: Thanks guys, I dont have any "&" in my code.But yes, popen solution sounds better. I will give it a spin. On 8/21/06, Ezra Zygmuntowicz wrote: > > > Yeah Charles has the right idea. One other way to do what you want > would be to kill the process directly by running > > pid = `ps axww | grep -v grep | grep typo` # or whatever the process > is called? > > then get the pid out of that text and do a kill -9 on it. But I think > you are probably better off with a popen solution. I am going to be > redoing the start scripts to use the daemons gem which might fix this > problem. > > -Ezra > > On Aug 21, 2006, at 8:29 AM, Charles Brian Quinn wrote: > > > Many times those calls to start/stop scripts get backgrounded, so it > > could actually be returning instantly. You could try wrapping it, or > > go check what typo stop is actually doing and make sure there's no > > "blah blah &" in the script. > > > > You could also try using popen and popen3 processes instead of the > > `command` backticks. I find those hard to debug as you don't know > > what's going on when they run. > > > > This will allow you to see stdin, stderr, and stdout on the > > process. Sample: > > > > cmd_to_run = "typo stop" > > > > stdin, stdout, stderr = Open3.popen3(cmd_to_run) > > > > s_stderr = stderr.read.to_s > > s_stdout = stdout.read.to_s > > > > # if you'd like to see it > > logger.info "stdout: #{s_stdout}" > > logger.info "stderr: #{s_stderr}" > > > > if s_stderr.empty? && s_stdout.starts_with?("error stuff here") > > return true > > else > > errors.add_to_base("error msg here") > > return false > > end > > > > hope that helps! > > > > On 8/21/06, hemant wrote: > >> Hi, > >> > >> I am using backgroundrb to create a automated system of typo > >> blogs.So, users > >> can create new typo applications using web interface and all that > >> jazz. > >> > >> Now..its working perfectly except one minor glitch. Since latest > >> version of > >> typo has a command called "typo", i simply use that command to > >> install new > >> typo app.And it works. > >> > >> def do_work(args) > >> DIR = "/home/foobar/public_html" > >> username = args > >> blog_name = username + "_blog" > >> # creation part works flawlessly so lets skip that. > >> # there is a problem while stopping it. > >> if (Dir.chdir(DIR)) == 0 > >> current_dir = `pwd` > >> @logger.debug("Current directory is #{current_dir}") > >> stop_command = "typo stop "+ blog_name > >> debug_stuff = `#{stop_command}` > >> #line no 33 > >> @logger.debug("### #{debug_stuff}") > >> else > >> @logger.debug("### Error changing directory") > >> end > >> end > >> Now let me assure that, args has correct username, because > >> starting of > >> blog,migrating from sqlite to mysql works perfectly using this worker > >> thread.The only glitch is, in line # 33, "typo stop " doesn't > >> work.I have > >> tried system also.system returns true, so typo should be > >> stopped.But when i > >> do "ps aux|grep foobar" , it isn't ,process is still there. > >> > >> When i tried `command`. All i got in debug_stuff variable is a empty > >> string.However, when i try same stuff from irb, it works as > >> expected and > >> typo stopped.Now..again let me assure that, the worker thread IS > >> getting > >> CALLED. > >> > >> I have tried various stuff.But since, I am simply not able to > >> debug, where > >> the heck problem is, I am lost. I was told that, system or > >> `command` both > >> wait for the command to finish execution to resume normal > >> execution.But for > >> me it SEEMS that the call to "typo stop #{blog_name}" returns > >> immediately. > >> > >> > >> > >> > >> _______________________________________________ > >> 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 > > _______________________________________________ > > Backgroundrb-devel mailing list > > Backgroundrb-devel at rubyforge.org > > http://rubyforge.org/mailman/listinfo/backgroundrb-devel > > -- nothing much to talk -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060822/bff59dbb/attachment.html From hammed at gmail.com Mon Aug 21 19:44:00 2006 From: hammed at gmail.com (Hammed Malik) Date: Tue, 22 Aug 2006 09:44:00 +1000 Subject: [Backgroundrb-devel] subscribe Message-ID: <5440c2a90608211644r5a218d00g32bf7e83b587722d@mail.gmail.com> -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060822/ba4ce794/attachment.html From fernand.galiana at gmail.com Wed Aug 23 02:50:53 2006 From: fernand.galiana at gmail.com (Fernand Galiana) Date: Wed, 23 Aug 2006 00:50:53 -0600 Subject: [Backgroundrb-devel] Auto-Reload... Message-ID: <30ab479c0608222350n48957e9ak4a587b3573f3c0a5@mail.gmail.com> Hi, Not sure if this was posted before.... Is there a way to tell the backgroundrb server to reload workers a la rails in dev mode ? It seems that I have to cycle the server everytime I change my workers... Also has anyone cooked up a script for monitoring the background drb process on a nix OS ? ie rc init for server startup and making sure the process is happy thereafter... Thank you all, -Fernand -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060823/b8a1e8b0/attachment.html From info at siebert-wd.de Wed Aug 23 14:33:53 2006 From: info at siebert-wd.de (Michael Siebert) Date: Wed, 23 Aug 2006 20:33:53 +0200 Subject: [Backgroundrb-devel] Singleton-like Worker Message-ID: <32b567370608231133x74c0076el5a85826e5c3ff5ab@mail.gmail.com> Hello there, I need a Worker Class to be Singleton-like, that means there must be at maximum one Instance at a time. When a new Request is made to create another worker of this type, it should return and wait for the other instance to be destroyed. what i need to do: i have a worker who needs to do sth with java and openoffice, and it seems when i have more tha one worker simultaneously, everything goes terribly wrong... is there already sth in bgdrb or how would i do that? -- Michael Siebert www.siebert-wd.de - Gedanken lesen www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060823/556e6625/attachment.html From ezmobius at gmail.com Wed Aug 23 14:39:30 2006 From: ezmobius at gmail.com (Ezra Zygmuntowicz) Date: Wed, 23 Aug 2006 11:39:30 -0700 Subject: [Backgroundrb-devel] Auto-Reload... In-Reply-To: <30ab479c0608222350n48957e9ak4a587b3573f3c0a5@mail.gmail.com> References: <30ab479c0608222350n48957e9ak4a587b3573f3c0a5@mail.gmail.com> Message-ID: <30784BB9-6A92-44B8-A935-D95EF8B4ABC9@gmail.com> On Aug 22, 2006, at 11:50 PM, Fernand Galiana wrote: > Hi, > > Not sure if this was posted before.... > > Is there a way to tell the backgroundrb server to reload > workers a la rails in dev mode ? > It seems that I have to cycle the server everytime I change my > workers... > > Also has anyone cooked up a script for monitoring the > background drb process on a nix OS ? > ie rc init for server startup and making sure the process is > happy thereafter... > > Thank you all, > > -Fernand > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel Hey Fernand- Yeah that will be in the next release. I have most of the code for it done so it should be soon. It will also include breakpoint support. -Ezra From ezmobius at gmail.com Wed Aug 23 14:42:17 2006 From: ezmobius at gmail.com (Ezra Zygmuntowicz) Date: Wed, 23 Aug 2006 11:42:17 -0700 Subject: [Backgroundrb-devel] Singleton-like Worker In-Reply-To: <32b567370608231133x74c0076el5a85826e5c3ff5ab@mail.gmail.com> References: <32b567370608231133x74c0076el5a85826e5c3ff5ab@mail.gmail.com> Message-ID: <05FA633B-C3C4-4CE2-B6BE-6CDCBA959BDA@gmail.com> On Aug 23, 2006, at 11:33 AM, Michael Siebert wrote: > Hello there, > I need a Worker Class to be Singleton-like, that means there must > be at maximum one Instance at a time. When a new Request is made to > create another worker of this type, it should return and wait for > the other instance to be destroyed. > > what i need to do: i have a worker who needs to do sth with java > and openoffice, and it seems when i have more tha one worker > simultaneously, everything goes terribly wrong... > > is there already sth in bgdrb or how would i do that? > > -- > Michael Siebert > Hey Michael- Yeah there is already singleton type workers in the plugin. It doesn't work exactly as you want it to though. When you create a singleton worker it will start doing its thing and any call to new_worker for the same singleton will just return the key for the already existing singleton worker. So you are always garaunteed to get the same singleton. There is not currently any support for returning and then starting up after the singleton dies. But check it out anyway as it might do what you want. There is also now an option to have a singleton worker so there is always only one of a certain worker. Even if you call new_worker twice with this option enabled you will get back the same instance of the class. Do not create a worker class and use it as a singleton and a non singleton worker at the same time. This is not supported. MiddleMan.new_worker(:class => :foo_worker, :args => "Bar", :job_key => :singleton_worker, :singleton => true) -Ezra -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060823/c18dc769/attachment-0001.html From info at siebert-wd.de Wed Aug 23 15:30:40 2006 From: info at siebert-wd.de (Michael Siebert) Date: Wed, 23 Aug 2006 21:30:40 +0200 Subject: [Backgroundrb-devel] Singleton-like Worker In-Reply-To: <05FA633B-C3C4-4CE2-B6BE-6CDCBA959BDA@gmail.com> References: <32b567370608231133x74c0076el5a85826e5c3ff5ab@mail.gmail.com> <05FA633B-C3C4-4CE2-B6BE-6CDCBA959BDA@gmail.com> Message-ID: <32b567370608231230u122c8d2dwc4892e6a57101cba@mail.gmail.com> built upon the singleton code, i made a little option :queue_run and modified Backgroundrb::rails to wait in that case. little hackery though, but it works. wanna have it? (as always not tested, no unit tests no nothing) 2006/8/23, Ezra Zygmuntowicz : > > > On Aug 23, 2006, at 11:33 AM, Michael Siebert wrote: > > Hello there, > I need a Worker Class to be Singleton-like, that means there must be at > maximum one Instance at a time. When a new Request is made to create another > worker of this type, it should return and wait for the other instance to be > destroyed. > > what i need to do: i have a worker who needs to do sth with java and > openoffice, and it seems when i have more tha one worker simultaneously, > everything goes terribly wrong... > > is there already sth in bgdrb or how would i do that? > > -- > Michael Siebert > > > Hey Michael- > > Yeah there is already singleton type workers in the plugin. It doesn't > work exactly as you want it to though. When you create a singleton worker it > will start doing its thing and any call to new_worker for the same singleton > will just return the key for the already existing singleton worker. So you > are always garaunteed to get the same singleton. There is not currently any > support for returning and then starting up after the singleton dies. But > check it out anyway as it might do what you want. > > There is also now an option to have a singleton worker so there is always > only one of a certain worker. Even if you call new_worker twice with this > option enabled you will get back the same instance of the class. Do not > create a worker class and use it as a singleton and a non singleton worker > at the same time. This is not supported. > > MiddleMan.new_worker(:class => :foo_worker, > :args => "Bar", > :job_key => :singleton_worker, > :singleton => true) > > > -Ezra > > -- Michael Siebert www.siebert-wd.de - Gedanken lesen www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060823/9d2fedab/attachment.html From ezmobius at gmail.com Wed Aug 23 15:44:23 2006 From: ezmobius at gmail.com (Ezra Zygmuntowicz) Date: Wed, 23 Aug 2006 12:44:23 -0700 Subject: [Backgroundrb-devel] Singleton-like Worker In-Reply-To: <32b567370608231230u122c8d2dwc4892e6a57101cba@mail.gmail.com> References: <32b567370608231133x74c0076el5a85826e5c3ff5ab@mail.gmail.com> <05FA633B-C3C4-4CE2-B6BE-6CDCBA959BDA@gmail.com> <32b567370608231230u122c8d2dwc4892e6a57101cba@mail.gmail.com> Message-ID: <6A1E38F7-D179-48C4-8F22-6507FB5A82E9@brainspl.at> Sure I will take a look at it. But I might wait until after I implement a thread pool to add it in. I am planning to make a configurable thread pool for workers. So you could say that 30 workers can be running at a time max. Then when you already have 30 workers running, and you ask it to run another that one will go into the wait pool until one of the first 30 finishes and makes room. This will make it safer to run a lot of workers and you will be able to taylor the size of the pool to fit your situation. But yeah do send me the code so I can see what you did. Cheers- -Ezra On Aug 23, 2006, at 12:30 PM, Michael Siebert wrote: > built upon the singleton code, i made a little option :queue_run > and modified Backgroundrb::rails to wait in that case. little > hackery though, but it works. > wanna have it? (as always not tested, no unit tests no nothing) > > 2006/8/23, Ezra Zygmuntowicz : > > On Aug 23, 2006, at 11:33 AM, Michael Siebert wrote: > >> Hello there, >> I need a Worker Class to be Singleton-like, that means there must >> be at maximum one Instance at a time. When a new Request is made >> to create another worker of this type, it should return and wait >> for the other instance to be destroyed. >> >> what i need to do: i have a worker who needs to do sth with java >> and openoffice, and it seems when i have more tha one worker >> simultaneously, everything goes terribly wrong... >> >> is there already sth in bgdrb or how would i do that? >> >> -- >> Michael Siebert >> > > Hey Michael- > > Yeah there is already singleton type workers in the plugin. It > doesn't work exactly as you want it to though. When you create a > singleton worker it will start doing its thing and any call to > new_worker for the same singleton will just return the key for the > already existing singleton worker. So you are always garaunteed to > get the same singleton. There is not currently any support for > returning and then starting up after the singleton dies. But check > it out anyway as it might do what you want. > > There is also now an option to have a singleton worker so there is > always > only one of a certain worker. Even if you call new_worker twice > with this > option enabled you will get back the same instance of the class. Do > not > create a worker class and use it as a singleton and a non singleton > worker > at the same time. This is not supported. > > MiddleMan.new_worker(:class => :foo_worker, > :args => "Bar", > :job_key => :singleton_worker, > :singleton => true) > > > -Ezra > > > > > -- > Michael Siebert > > www.siebert-wd.de - Gedanken lesen > www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060823/9c0779e9/attachment.html From mark at martianrover.com Wed Aug 23 16:27:34 2006 From: mark at martianrover.com (P. Mark Anderson) Date: Wed, 23 Aug 2006 13:27:34 -0700 Subject: [Backgroundrb-devel] Singleton-like Worker In-Reply-To: <6A1E38F7-D179-48C4-8F22-6507FB5A82E9@brainspl.at> References: <32b567370608231133x74c0076el5a85826e5c3ff5ab@mail.gmail.com> <05FA633B-C3C4-4CE2-B6BE-6CDCBA959BDA@gmail.com> <32b567370608231230u122c8d2dwc4892e6a57101cba@mail.gmail.com> <6A1E38F7-D179-48C4-8F22-6507FB5A82E9@brainspl.at> Message-ID: +1 useful on the thread pool. I can't wait. Really. The queue I wrote has two priority levels so that quick or important tasks execute before those of normal priority. It'd be great if Backgroundrb managed it all. pmark On Aug 23, 2006, at 12:44 PM, Ezra Zygmuntowicz wrote: > > Sure I will take a look at it. But I might wait until after I > implement a thread pool to add it in. I am planning to make a > configurable thread pool for workers. So you could say that 30 > workers can be running at a time max. Then when you already have 30 > workers running, and you ask it to run another that one will go > into the wait pool until one of the first 30 finishes and makes > room. This will make it safer to run a lot of workers and you will > be able to taylor the size of the pool to fit your situation. But > yeah do send me the code so I can see what you did. > > Cheers- > -Ezra > > > On Aug 23, 2006, at 12:30 PM, Michael Siebert wrote: > >> built upon the singleton code, i made a little option :queue_run >> and modified Backgroundrb::rails to wait in that case. little >> hackery though, but it works. >> wanna have it? (as always not tested, no unit tests no nothing) >> >> 2006/8/23, Ezra Zygmuntowicz : >> >> On Aug 23, 2006, at 11:33 AM, Michael Siebert wrote: >> >>> Hello there, >>> I need a Worker Class to be Singleton-like, that means there must >>> be at maximum one Instance at a time. When a new Request is made >>> to create another worker of this type, it should return and wait >>> for the other instance to be destroyed. >>> >>> what i need to do: i have a worker who needs to do sth with java >>> and openoffice, and it seems when i have more tha one worker >>> simultaneously, everything goes terribly wrong... >>> >>> is there already sth in bgdrb or how would i do that? >>> >>> -- >>> Michael Siebert >>> >> >> Hey Michael- >> >> Yeah there is already singleton type workers in the plugin. It >> doesn't work exactly as you want it to though. When you create a >> singleton worker it will start doing its thing and any call to >> new_worker for the same singleton will just return the key for the >> already existing singleton worker. So you are always garaunteed to >> get the same singleton. There is not currently any support for >> returning and then starting up after the singleton dies. But check >> it out anyway as it might do what you want. >> >> There is also now an option to have a singleton worker so there is >> always >> only one of a certain worker. Even if you call new_worker twice >> with this >> option enabled you will get back the same instance of the class. >> Do not >> create a worker class and use it as a singleton and a non >> singleton worker >> at the same time. This is not supported. >> >> MiddleMan.new_worker(:class => :foo_worker, >> :args => "Bar", >> :job_key => :singleton_worker, >> :singleton => true) >> >> >> -Ezra >> >> >> >> >> -- >> Michael Siebert >> >> www.siebert-wd.de - Gedanken lesen >> www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium >> _______________________________________________ >> Backgroundrb-devel mailing list >> Backgroundrb-devel at rubyforge.org >> http://rubyforge.org/mailman/listinfo/backgroundrb-devel > > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060823/88b9cb5a/attachment.html From fernand.galiana at gmail.com Wed Aug 23 16:59:58 2006 From: fernand.galiana at gmail.com (Fernand Galiana) Date: Wed, 23 Aug 2006 14:59:58 -0600 Subject: [Backgroundrb-devel] Auto-Reload... In-Reply-To: <30784BB9-6A92-44B8-A935-D95EF8B4ABC9@gmail.com> References: <30ab479c0608222350n48957e9ak4a587b3573f3c0a5@mail.gmail.com> <30784BB9-6A92-44B8-A935-D95EF8B4ABC9@gmail.com> Message-ID: <30ab479c0608231359p55faf3beg3492762eea500cd@mail.gmail.com> Very cool !! Thanks for your on going effort... -Fernand On 8/23/06, Ezra Zygmuntowicz wrote: > > > On Aug 22, 2006, at 11:50 PM, Fernand Galiana wrote: > > > Hi, > > > > Not sure if this was posted before.... > > > > Is there a way to tell the backgroundrb server to reload > > workers a la rails in dev mode ? > > It seems that I have to cycle the server everytime I change my > > workers... > > > > Also has anyone cooked up a script for monitoring the > > background drb process on a nix OS ? > > ie rc init for server startup and making sure the process is > > happy thereafter... > > > > Thank you all, > > > > -Fernand > > _______________________________________________ > > Backgroundrb-devel mailing list > > Backgroundrb-devel at rubyforge.org > > http://rubyforge.org/mailman/listinfo/backgroundrb-devel > > > Hey Fernand- > > Yeah that will be in the next release. I have most of the code for > it done so it should be soon. It will also include breakpoint support. > > -Ezra > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060823/cac3262c/attachment-0001.html From david at lemstra.ca Wed Aug 23 18:21:39 2006 From: david at lemstra.ca (David Lemstra) Date: Wed, 23 Aug 2006 18:21:39 -0400 Subject: [Backgroundrb-devel] Singleton-like Worker In-Reply-To: References: <32b567370608231133x74c0076el5a85826e5c3ff5ab@mail.gmail.com> <05FA633B-C3C4-4CE2-B6BE-6CDCBA959BDA@gmail.com> <32b567370608231230u122c8d2dwc4892e6a57101cba@mail.gmail.com> <6A1E38F7-D179-48C4-8F22-6507FB5A82E9@brainspl.at> Message-ID: <44ECD4F3.9080500@lemstra.ca> Funny, I've been working on this for over a day now. It uses a autostart singleton worker QueueWorker that acts as an intermediary to your actual child workers. It sets up an array of watchdog threads that each grab {args} from a queue and spawns a new child worker when the previous child worker in the slot is finished. It takes several layers of mutexes to make it all work but thanks to singleton workers, its done w/ hardly any changes to the current code. The original question cold be resolved by using this w/ just one watchdog thread. Yeah, eventually plan to add a priority Q as well... Its's really messy right now though and am going on a week vacation tomorrow. will send the dirty version if I don't get it cleaned up by then. cheers, David Lemstra P. Mark Anderson wrote: > +1 useful on the thread pool. I can't wait. Really. The queue I wrote > has two priority levels so that quick or important tasks execute before > those of normal priority. It'd be great if Backgroundrb managed it all. > > pmark > > > > > On Aug 23, 2006, at 12:44 PM, Ezra Zygmuntowicz wrote: > >> >> Sure I will take a look at it. But I might wait until after I >> implement a thread pool to add it in. I am planning to make a >> configurable thread pool for workers. So you could say that 30 workers >> can be running at a time max. Then when you already have 30 workers >> running, and you ask it to run another that one will go into the wait >> pool until one of the first 30 finishes and makes room. This will make >> it safer to run a lot of workers and you will be able to taylor the >> size of the pool to fit your situation. But yeah do send me the code >> so I can see what you did. >> >> Cheers- >> -Ezra >> >> >> On Aug 23, 2006, at 12:30 PM, Michael Siebert wrote: >> >>> built upon the singleton code, i made a little option :queue_run and >>> modified Backgroundrb::rails to wait in that case. little hackery >>> though, but it works. >>> wanna have it? (as always not tested, no unit tests no nothing) >>> >>> 2006/8/23, Ezra Zygmuntowicz >> >: >>> >>> >>> On Aug 23, 2006, at 11:33 AM, Michael Siebert wrote: >>> >>>> Hello there, >>>> I need a Worker Class to be Singleton-like, that means there >>>> must be at maximum one Instance at a time. When a new Request is >>>> made to create another worker of this type, it should return and >>>> wait for the other instance to be destroyed. >>>> >>>> what i need to do: i have a worker who needs to do sth with java >>>> and openoffice, and it seems when i have more tha one worker >>>> simultaneously, everything goes terribly wrong... >>>> >>>> is there already sth in bgdrb or how would i do that? >>>> >>>> -- >>>> Michael Siebert > >>>> >>> >>> Hey Michael- >>> >>> Yeah there is already singleton type workers in the plugin. It >>> doesn't work exactly as you want it to though. When you create a >>> singleton worker it will start doing its thing and any call to >>> new_worker for the same singleton will just return the key for >>> the already existing singleton worker. So you are always >>> garaunteed to get the same singleton. There is not currently any >>> support for returning and then starting up after the singleton >>> dies. But check it out anyway as it might do what you want. >>> >>> There is also now an option to have a singleton worker so there >>> is always >>> only one of a certain worker. Even if you call new_worker twice >>> with this >>> option enabled you will get back the same instance of the class. >>> Do not >>> create a worker class and use it as a singleton and a non >>> singleton worker >>> at the same time. This is not supported. >>> >>> MiddleMan.new_worker(:class => :foo_worker, >>> :args => "Bar", >>> :job_key => :singleton_worker, >>> :singleton => true) >>> >>> >>> -Ezra >>> >>> From me at seebq.com Thu Aug 24 00:36:13 2006 From: me at seebq.com (Charles Brian Quinn) Date: Thu, 24 Aug 2006 00:36:13 -0400 Subject: [Backgroundrb-devel] Auto-Reload... In-Reply-To: <30ab479c0608231359p55faf3beg3492762eea500cd@mail.gmail.com> References: <30ab479c0608222350n48957e9ak4a587b3573f3c0a5@mail.gmail.com> <30784BB9-6A92-44B8-A935-D95EF8B4ABC9@gmail.com> <30ab479c0608231359p55faf3beg3492762eea500cd@mail.gmail.com> Message-ID: <3a2de0cd0608232136i4ffd882m247d30c17f0e00c0@mail.gmail.com> As for the process for keeping it running, that's interesting -- I would look into supervise -- a linux daemon for supervising processes to make sure they're up. qmail uses this pretty extensively.... On 8/23/06, Fernand Galiana wrote: > Very cool !! Thanks for your on going effort... > > -Fernand > > > On 8/23/06, Ezra Zygmuntowicz wrote: > > > > On Aug 22, 2006, at 11:50 PM, Fernand Galiana wrote: > > > > > Hi, > > > > > > Not sure if this was posted before.... > > > > > > Is there a way to tell the backgroundrb server to reload > > > workers a la rails in dev mode ? > > > It seems that I have to cycle the server everytime I change my > > > workers... > > > > > > Also has anyone cooked up a script for monitoring the > > > background drb process on a nix OS ? > > > ie rc init for server startup and making sure the process is > > > happy thereafter... > > > > > > Thank you all, > > > > > > -Fernand > > > _______________________________________________ > > > Backgroundrb-devel mailing list > > > Backgroundrb-devel at rubyforge.org > > > > http://rubyforge.org/mailman/listinfo/backgroundrb-devel > > > > > > Hey Fernand- > > > > Yeah that will be in the next release. I have most of the code for > > it done so it should be soon. It will also include breakpoint support. > > > > -Ezra > > > > > _______________________________________________ > 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 From david at lemstra.ca Thu Aug 24 00:43:46 2006 From: david at lemstra.ca (David Lemstra) Date: Thu, 24 Aug 2006 00:43:46 -0400 Subject: [Backgroundrb-devel] A new QueueWorker class Message-ID: <44ED2E82.8070800@lemstra.ca> Hello all, I've come up w/ a worker class that manages queued jobs using a fixed number of child workers. Well, that's not quite true -- a new worker is spawned for each job, but you set the total number that may exist at once. There are three components: 1) queue_worker.rb: The singleton worker that manages the child workers. You probably want to auto start this. Make sure you give it :singleton=>true. Read this file for the methods to interact with your children. (ie. queue_job(), delete_job(), job_progress() ) 2) backgroundrb_rails_queue.rb: The super class for the "child workers" (and uses backgroundrb_rails.rb in turn). This file needs to be included in background.rb 3) Your child worker, which should be a subclass of BackgrounDRb::RailsQueue, is otherwise the about same as normal If it's a big loop, you probably want to use terminate?() on each iteration and update @progress. Use suicide() at the end to make room for the next child. Options: (probably in your backgroundrb.yml) autostart: :queue_key: class: queue_worker args: :num_child_workers: 2 :child_class: :cost_calculator_worker :reQ_on_finish: true :singleton: true :queue_key can be changed to what you want, but it is the permanent key of the QueueWorker :num_child_workers: is up to you! :child_class: your worker class you want as child workers. :reQ_on_finish: do you want results to be stored in the queue until you call job_progress!() ? Note: to be able to access your child jobs w/ the QueueWorker methods, include a unique :id in your {args} when you queue_job({args}) I'll attach the files. If they don't go through, I'll resend as text. BTW, This works well enough for me, but I'm learning as I go too, so no guarantees :) I don't use the fancy timing options, so ymmmv for :next_start and :interval. Let me know if you find any issues (though I'm off-line for a week after this post). I'm wondering myself if it might be better to reuse child workers instead of re-spawning new ones. Another day maybe. cheers, David Lemstra -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: queue_worker.rb Url: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060824/2349e2f4/attachment.ksh -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: backgroundrb_rails_queue.rb Url: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060824/2349e2f4/attachment-0001.ksh From ezmobius at gmail.com Thu Aug 24 02:41:13 2006 From: ezmobius at gmail.com (Ezra Zygmuntowicz) Date: Wed, 23 Aug 2006 23:41:13 -0700 Subject: [Backgroundrb-devel] A new QueueWorker class In-Reply-To: <44ED2E82.8070800@lemstra.ca> References: <44ED2E82.8070800@lemstra.ca> Message-ID: Wow! Thats pretty thick ;) I'll work my way through it this weekend and see how it works. Thanks -Ezra On Aug 23, 2006, at 9:43 PM, David Lemstra wrote: > Hello all, > I've come up w/ a worker class that manages queued jobs using a fixed > number of child workers. Well, that's not quite true -- a new > worker is > spawned for each job, but you set the total number that may exist > at once. > > There are three components: > 1) queue_worker.rb: The singleton worker that manages the child > workers. > You probably want to auto start this. Make sure you give it > :singleton=>true. Read this file for the methods to interact with your > children. (ie. queue_job(), delete_job(), job_progress() ) > > 2) backgroundrb_rails_queue.rb: The super class for the "child > workers" > (and uses backgroundrb_rails.rb in turn). This file needs to be > included > in background.rb > > 3) Your child worker, which should be a subclass of > BackgrounDRb::RailsQueue, is otherwise the about same as normal > If it's a big loop, you probably want to use terminate?() on each > iteration and update @progress. Use suicide() at the end to make room > for the next child. > > Options: (probably in your backgroundrb.yml) > autostart: > :queue_key: > class: queue_worker > args: > :num_child_workers: 2 > :child_class: :cost_calculator_worker > :reQ_on_finish: true > :singleton: true > > :queue_key can be changed to what you want, but it is the permanent > key > of the QueueWorker > :num_child_workers: is up to you! > :child_class: your worker class you want as child workers. > :reQ_on_finish: do you want results to be stored in the queue until > you > call job_progress!() ? > Note: to be able to access your child jobs w/ the QueueWorker methods, > include a unique :id in your {args} when you queue_job({args}) > > I'll attach the files. If they don't go through, I'll resend as text. > > BTW, This works well enough for me, but I'm learning as I go too, > so no > guarantees :) I don't use the fancy timing options, so ymmmv for > :next_start and :interval. > > Let me know if you find any issues (though I'm off-line for a week > after > this post). I'm wondering myself if it might be better to reuse child > workers instead of re-spawning new ones. Another day maybe. > > cheers, > David Lemstra > # Put your code that runs your task inside the do_work method > # it will be run automatically in a thread. You have access to > # all of your rails models if you set load_rails to true in the > # config file. You also get @logger inside of this class by default. > require 'monitor.rb' > > class QueueWorker < BackgrounDRb::Rails > > attr_reader :q, :id_hash, :completed > def initialize(key, args={}) > super(key,args) > @num_child_workers = args[:num_child_workers] ? args > [:num_child_workers] : 1 > @child_workers = Array.new(@num_child_workers) {|i| Hash > [:job_key,nil,:args,nil,:s_thread,nil, :s_mutex,Mutex.new, :child, > i] } > > @q = [] > @q.extend(MonitorMixin) > @q_loaded_cv = @q.new_cond > @id_hash = {} > @id_hash_mutex = Mutex.new > > raise ArgumentError unless args.has_key?(:child_class) > @child_class = args[:child_class] > @reQ_on_finish = args[:reQ_on_finish] || false > @completed = 0 > end > > def queue_job(args) > return nil if @id_hash && args[:id] && @id_hash.has_key?(args > [:id]) > @q.synchronize do > @q.push args > @id_hash_mutex.synchronize { @id_hash[args[:id]] = > {:status=>:queued, :job_key=>nil, :results=>nil } } if args[:id] > @q_loaded_cv.signal > end > return true > end > > def job_in_progress?(job_id) > @id_hash.has_key?(job_id) > end > > def job_status?(job_id) > @id_hash_mutex.synchronize do > return nil unless @id_hash.has_key?(job_id) > return @id_hash[job_key][:status] > end > end > > def job_progress(job_id) > report_hsh = {} > @id_hash_mutex.synchronize do > return nil unless @id_hash.has_key?(job_id) > report_hsh[:status] = @id_hash[job_id][:status] > report_hsh[:progress] = case @id_hash[job_id][:status] > when :queued then > ahead = 0 > @q.each_index {|i| if @q[i][:id] == job_id then ahead = > i; break; end } > ahead > when :running > w = self[@id_hash[job_id][:job_key]] > w.nil? ? nil : w.progress > when :done > @id_hash[job_id][:results] > else nil > end > end > return report_hsh > end > > def job_progress!(job_id) > report_hsh = {} > @id_hash_mutex.synchronize do > return nil unless @id_hash.has_key?(job_id) > report_hsh[:status] = @id_hash[job_id][:status] > report_hsh[:progress] = case @id_hash[job_id][:status] > when :queued then > ahead = 0 > @q.each_index {|i| if @q[i][:id] == job_id then ahead = > i; break; end } > ahead > when :running > w = self[@id_hash[job_id][:job_key]] > if w.nil? > @id_hash.delete(job_id)[:results] > else > w.progress > end > when :done > @id_hash.delete(job_id)[:results] > else nil > end > end > return report_hsh > end > > def delete_job(job_id) > args = nil > @q.synchronize do @id_hash_mutex.synchronize do > args = @id_hash[job_id] > return true if args.nil? > if args[:status] == :queued > @q.delete_if {|h| h[:id] == job_id } > @id_hash.delete(job_id) > return true > elsif args[:status] == :done > @id_hash.delete(job_id) > return true > end > end > end > ::BackgrounDRb::MiddleMan.instance.delete_worker(args > [:job_key]) if args[:status] == :running > return true > end > > def do_work(args) > # You probably don't want to mess with this method unless you > know what's what. > @child_workers.each do |child_hash| > child_hash[:s_thread] = Thread.start do > loop do > # Wait for a new job in the @q > child_hash[:s_mutex].synchronize do > # get the Q mutex and wait for a job > @q.synchronize do > tl = Thread.list > @q_loaded_cv.wait_while { @q.empty? } > child_hash[:args] = @q.shift > if child_hash[:args][:id] > @id_hash_mutex.synchronize do > @id_hash[child_hash[:args][:id]][:status] = :running > child_hash[:job_key] = spawn_worker > ({:args=>child_hash[:args],:class=>@child_class}) > @id_hash[child_hash[:args][:id]][:job_key] = > child_hash[:job_key] > end > else > child_hash[:job_key] = spawn_worker(job_args.merge > (:class=>@child_class)) > end > end > self[child_hash[:job_key]].thread[:DQ_request].wait > (child_hash[:s_mutex]) > # grab and store the results > if child_hash[:args][:id] > @id_hash_mutex.synchronize do > if @reQ_on_finish > r = self[child_hash[:job_key]].results > @id_hash[child_hash[:args][:id]][:results] = r if r > @id_hash[child_hash[:args][:id]][:status] = :done > @id_hash[child_hash[:args][:id]][:done_at] = > Time.now > else > @id_hash.delete(child_hash[:args][:id]) > end > end > end > self[child_hash[:job_key]].thread[:DQed].signal > @completed += 1 > [:args,:job_key].each {|k| child_hash[k] = nil } > end > # Loop back and wait for the job_key to get killed again.... > end > end > end > end > > private > > def [](key) > # Use jobs to avoid the access time update w/ [] > ::BackgrounDRb::MiddleMan.instance.jobs[key] > end > > end > module BackgrounDRb > > class RailsQueue < BackgrounDRb::Rails > attr_reader :progress > def initialize(key, args={}) > super(key,args) > @job_ctrl = true > end > > def start_process > return if schedule_first_run && schedule_first_run.to_i > > Time.now.to_i > @thread = Thread.new do > Thread.current[:safe_to_kill] = ConditionVariable.new > Thread.current[:kill] = false > Thread.current[:DQ_request] = ConditionVariable.new > Thread.current[:DQed] = ConditionVariable.new > Thread.current[:mutex] = Mutex.new > begin > Thread.current[:mutex].synchronize do > do_work(@args) > end > rescue Exception => e > @logger.error "#{ e.message } - (#{ e.class })" << "\n" > << (e.backtrace or []).join("\n") > end > end > @next_start = @interval.from_now if schedule_repeat > end > > def results > # Overwrite this method and set reQ_on_finish = true (in the > queue worker args) > # to have a process put it's results in back in the queue > # for pickup before being killed > nil > end > > def before_DQ(args=nil) > # stub method that gets called before dequeue is run. > # Overwrite in your class instance > true > end > > def terminate(args=nil) > do_DQ(args) > super(args) > end > > def suicide(args=nil) > do_DQ(args) > kill > Thread.exit > end > > private > def do_DQ(args=nil) > before_DQ(args) > Thread.current[:DQ_request].signal > Thread.current[:DQed].wait(Thread.current[:mutex]) > end > end > end_______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel From lapomme00 at gmail.com Thu Aug 24 05:13:17 2006 From: lapomme00 at gmail.com (Brett Walker) Date: Thu, 24 Aug 2006 17:13:17 +0800 Subject: [Backgroundrb-devel] Unable to start with Capistrano... Message-ID: I've created a couple of tasks in my deploy.rb file for starting and stopping backgroundrb on the remote server. The stop task runs fine and kills the process. And the start task *seems* to run successfully, but backgroundrb is never started on the remote host. Has anyone had success with this? Here are my deploy tasks: desc 'Start backgroundrb server (default values)' task :start_backgroundrb do puts "Starting BackgrounDRb" #--- assumes the backgroundrb.yml is set up for production run "export RAILS_ENV=production && #{current_path}/script/backgroundrb/start -d" end desc 'Stop backgroundrb server (default values)' task :stop_backgroundrb do puts "Stopping BackgrounDRb" begin run "#{current_path}/script/backgroundrb/stop" rescue end end I'm no doubt missing something obvious. Cheers, Brett From codeslush at yahoo.com Thu Aug 24 14:44:11 2006 From: codeslush at yahoo.com (Michael) Date: Thu, 24 Aug 2006 11:44:11 -0700 (PDT) Subject: [Backgroundrb-devel] Regarding New QueueWorker class Message-ID: <20060824184411.61817.qmail@web30709.mail.mud.yahoo.com> Hi Ezra/Community, I posted a few comments last night on the rails forum and followed Ezra's advice to come here! Lot's of good stuff in the archives that probably saved me much headache (specifically, ActionMailer related items). I saw this post - and am wondering if anyone else has had a chance yet to download the two source files and try it out. Queuing of work items is definitely a big asset and something that I will be trying to do. I'll try the code as well, but if anyone has had any initial success/problems with it then please advise and save me some time! I look forward to working with this group! Regards, Michael --------------------------------- Get your own web address for just $1.99/1st yr. We'll help. Yahoo! Small Business. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060824/ca8a1ffd/attachment.html From ezmobius at gmail.com Thu Aug 24 14:50:27 2006 From: ezmobius at gmail.com (Ezra Zygmuntowicz) Date: Thu, 24 Aug 2006 11:50:27 -0700 Subject: [Backgroundrb-devel] Regarding New QueueWorker class In-Reply-To: <20060824184411.61817.qmail@web30709.mail.mud.yahoo.com> References: <20060824184411.61817.qmail@web30709.mail.mud.yahoo.com> Message-ID: <118573E5-2C2C-484B-8488-81F208DDE6F0@gmail.com> On Aug 24, 2006, at 11:44 AM, Michael wrote: > Hi Ezra/Community, > > I posted a few comments last night on the rails forum and followed > Ezra's advice to come here! Lot's of good stuff in the archives > that probably saved me much headache (specifically, ActionMailer > related items). > > I saw this post - and am wondering if anyone else has had a chance > yet to download the two source files and try it out. Queuing of > work items is definitely a big asset and something that I will be > trying to do. I'll try the code as well, but if anyone has had any > initial success/problems with it then please advise and save me > some time! > > I look forward to working with this group! > > Regards, > > Michael The QueueWorker looks like it will work very well but I haven't had a chance to try it out yet though. I think that it might be better if the core MiddleMan held the Thread Pool. I hope to have time to work more on my thread pool impl now that I am done with my day job and on to greener pastures ;) We will see what I come up with. But for now by all means try out the new queue worker stuff and report back how it works for you. -Ezra P.S. Welcome to the list ;) From bjohnson at contuitive.com Thu Aug 24 17:08:36 2006 From: bjohnson at contuitive.com (Ben Johnson) Date: Thu, 24 Aug 2006 16:08:36 -0500 Subject: [Backgroundrb-devel] ActionMailer doesn't work in backgroundrb Message-ID: I am pretty confident that mailers do not work in backgroundrb. Can anyone confirm this? Because when I try to do Notifier.deliver_some_method I get an error saying it cant find the templates for my email. The funny thing is that when I run script/ runner Notifier.deliver_some_method it works just fine. Any ideas? Thank You, Ben Johnson E: bjohnson at contuitive.com O: 800-341-6826 M: 817-229-4258 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060824/9210b250/attachment.html From lapomme00 at gmail.com Fri Aug 25 01:18:23 2006 From: lapomme00 at gmail.com (Brett Walker) Date: Fri, 25 Aug 2006 13:18:23 +0800 Subject: [Backgroundrb-devel] repeat_every when a worker is not done yet... Message-ID: If I use repeat_every for a worker, if the do_work function has not completed by the time the next interval rolls around, will a new thread be started, resulting in 2 threads for the same worker? Looking at start_process, it seems like the thread gets created (which spins off the thread and then continues to execute the start_process method, right?), then sets the @next_start. So if the @next_start is in 10 minutes, but it takes 20 minutes to finish the current work, start_timer will attempt to call start_process on the job, and kick off another thread, resulting in 2 threads. Is this correct? What I want to happen is that the thread can't get kicked off again until the current one has completed/returned. Maybe the setting of @next_start needs to go in the thread block. Or did I totally misunderstand the code? Cheers, Brett From dgreig at magian.com Fri Aug 25 01:21:37 2006 From: dgreig at magian.com (Daniel Greig) Date: Fri, 25 Aug 2006 15:21:37 +1000 Subject: [Backgroundrb-devel] backgroundrb fails when running as win32 service Message-ID: <44EE88E1.1060009@magian.com> Hi, I've been playing with backgroundrb to batch process a bunch of images on a rails server. The process is working fine when backgroundrb is started from the command line, but seems to choke occasionally (well, quite often) when running as a service. It seems to get stuck on the following line when moving files: FileUtils.move(src, dest, :verbose => true) with the error: Bad file descriptor - (Errno::EBADF) For a while I thought it may have been a file permissions/file access issue, but I have seen another error where the process fails at a "puts" statement. I have a suspicion that the error may be occurring when ruby tries to write to the standard output using "puts". Since the "verbose" argument sends a message to the standard output, it could be failing for the same reason and just looking like a file move error. I have removed all puts statements and all verbose method calls and the service *seems* to be more reliable (although it's to early to say as I have to do a lot more testing). Has anyone seen any similar problems with the win32 service? My fingers are crossed that getting rid of the puts statements fixes the problem, but I'm nervous that it may be something else entirely - anyone have any ideas? thanks! Dan From gethemant at gmail.com Fri Aug 25 07:28:34 2006 From: gethemant at gmail.com (hemant) Date: Fri, 25 Aug 2006 16:58:34 +0530 Subject: [Backgroundrb-devel] uninitialised constant LoginEngine Message-ID: In my worker class, when i try to start the worker thread, it throws the error: uninitialized constant LoginEngine - (NameError) /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:123:in `const_missing' /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:131:in `const_missing' /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:133:in `const_missing' /home/foo_fighter/public_html/fooapp/config/../script/backgroundrb/../../config/../app/models/user.rb:3 /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:140:in `load' /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:56:in `require_or_load' /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:30:in `depend_on' /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:85:in `require_dependency' /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:98:in `const_missing' /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:131:in `const_missing' /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:133:in `const_missing' /home/foo_fighter/public_html/fooapp/config/../script/backgroundrb/../../config/../lib/workers/monitor_messageboards_worker.rb:18:in `do_work' /home/foo_fighter/public_html/fooapp/config/../script/backgroundrb/../../config/../vendor/plugins/backgroundrb/backgroundrb_rails.rb:35:in `start_process' /home/foo_fighter/public_html/fooapp/config/../script/backgroundrb/../../config/../vendor/plugins/backgroundrb/backgroundrb_rails.rb:31:in `start_process' /home/foo_fighter/public_html/fooapp/config/../script/backgroundrb/../../config/../vendor/plugins/backgroundrb/backgroundrb.rb:57:in `new_worker' /usr/lib/ruby/1.8/thread.rb:135:in `synchronize' /home/foo_fighter/public_html/fooapp/config/../script/backgroundrb/../../config/../vendor/plugins/backgroundrb/backgroundrb.rb:49:in `new_worker' /usr/lib/ruby/1.8/drb/drb.rb:1552:in `perform_without_block' /usr/lib/ruby/1.8/drb/drb.rb:1512:in `perform' /usr/lib/ruby/1.8/drb/drb.rb:1586:in `main_loop' /usr/lib/ruby/1.8/drb/drb.rb:1582:in `main_loop' /usr/lib/ruby/1.8/drb/drb.rb:1578:in `main_loop' /usr/lib/ruby/1.8/drb/drb.rb:1427:in `run' /usr/lib/ruby/1.8/drb/drb.rb:1424:in `run' /usr/lib/ruby/1.8/drb/drb.rb:1344:in `initialize' /usr/lib/ruby/1.8/drb/drb.rb:1624:in `start_service' /home/foo_fighter/public_html/fooapp/config/../script/backgroundrb/start:96 /home/foo_fighter/public_html/fooapp/config/../script/backgroundrb/start:92 /home/foo_fighter/public_html/fooapp/config/../script/backgroundrb/start:84 any ideas why? and how to prevent this? -- nothing much to talk -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060825/6feaee72/attachment.html From gethemant at gmail.com Fri Aug 25 07:39:43 2006 From: gethemant at gmail.com (hemant) Date: Fri, 25 Aug 2006 17:09:43 +0530 Subject: [Backgroundrb-devel] uninitialised constant LoginEngine In-Reply-To: References: Message-ID: I geuss, I am the one, who is asking this question again.I tried to search through, the mails, but clearly...following solutions didn't work for me: $: << "#{RAILS_ROOT}/vendor/plugins/engines/lib/engines" $: << "#{RAILS_ROOT}/vendor/plugins/login_engine/lib" Also, i last time, I worked around the problem by simply not using loginengine model class.But this time, as it seems i need this. There is a price to be paid, for using some readymade component. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060825/04dc27c1/attachment-0001.html From mklein at bpl.org Fri Aug 25 09:19:27 2006 From: mklein at bpl.org (Klein, Michael) Date: Fri, 25 Aug 2006 09:19:27 -0400 Subject: [Backgroundrb-devel] ActionMailer doesn't work in backgroundrb In-Reply-To: Message-ID: I haven?t used ActionMailer much myself, but based on past experience with missing files and background processes, I?m guessing this is either a missing or mis-set RAILS_ROOT environment variable, or a permissions problem. On 8/24/06 5:08 PM, "Ben Johnson" wrote: > I am pretty confident that mailers do not work in backgroundrb. Can anyone > confirm this? Because when I try to do Notifier.deliver_some_method I get an > error saying it cant find the templates for my email. The funny thing is that > when I run script/runner?Notifier.deliver_some_method it works just fine. Any > ideas? > > > > Thank You, > Ben Johnson > E: bjohnson at contuitive.com > O: 800-341-6826 > M: 817-229-4258 > > > > > > > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060825/c4163a51/attachment.html From ezmobius at gmail.com Fri Aug 25 11:13:24 2006 From: ezmobius at gmail.com (Ezra Zygmuntowicz) Date: Fri, 25 Aug 2006 08:13:24 -0700 Subject: [Backgroundrb-devel] uninitialised constant LoginEngine In-Reply-To: References: Message-ID: <1C459FFB-2FF5-4F88-9DA3-EDFF93EEC14C@brainspl.at> On Aug 25, 2006, at 4:39 AM, hemant wrote: > I geuss, I am the one, who is asking this question again.I tried to > search through, the mails, but clearly...following solutions didn't > work for me: > > $: << "#{RAILS_ROOT}/vendor/plugins/engines/lib/engines" > $: << "#{RAILS_ROOT}/vendor/plugins/login_engine/lib" > > Also, i last time, I worked around the problem by simply not using > loginengine model class.But this time, as it seems i need this. > There is a price to be paid, for using some readymade component. > > > > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel Hey Hemant- What I think you need to do is open up the start script and replace the line that require's boot.rb and make it require environment.rb., THat way it will go through rails normal load process and your engines will get loaded as well. This has bitten enough people that I am going to change it so that by default it will require all of rails if you set load_rails to true in your config file. Its an inconosistency on my part the way it works now. Cheers- -Ezra From ezmobius at gmail.com Fri Aug 25 11:14:56 2006 From: ezmobius at gmail.com (Ezra Zygmuntowicz) Date: Fri, 25 Aug 2006 08:14:56 -0700 Subject: [Backgroundrb-devel] repeat_every when a worker is not done yet... In-Reply-To: References: Message-ID: <4667952B-0A86-40DD-876A-DA4E2B6C54EE@gmail.com> On Aug 24, 2006, at 10:18 PM, Brett Walker wrote: > If I use repeat_every for a worker, if the do_work function has not > completed by the time the next interval rolls around, will a new > thread be started, resulting in 2 threads for the same worker? > > Looking at start_process, it seems like the thread gets created (which > spins off the thread and then continues to execute the start_process > method, right?), then sets the @next_start. So if the @next_start is > in 10 minutes, but it takes 20 minutes to finish the current work, > start_timer will attempt to call start_process on the job, and kick > off another thread, resulting in 2 threads. > > Is this correct? What I want to happen is that the thread can't get > kicked off again until the current one has completed/returned. Maybe > the setting of @next_start needs to go in the thread block. Or did I > totally misunderstand the code? > > Cheers, > Brett Hey Brett- You know I think you are correct. It looks like if your worker lasts longer then the interval that you will end up with multiple worker threads. Hmm.. I personally haven't used the repeat_every stuff. I added unit tests for it when the patch was submitted but I don't think I considered the case you are talking about. I am in the middle of a wholesale refactoring of the codebase in order to add a thread pool and more precise timed workers. Hopefully sometime next week I will have a release. If you need this right away then I would happily accept a patch for more detailed cron style workers. Cheers- -Ezra From ezmobius at gmail.com Fri Aug 25 11:42:48 2006 From: ezmobius at gmail.com (Ezra Zygmuntowicz) Date: Fri, 25 Aug 2006 08:42:48 -0700 Subject: [Backgroundrb-devel] Small Update: load_rails now actually loads rails Message-ID: <7CFA98A6-5069-451E-9F34-FAAEC187535E@gmail.com> Folks- After enough people running into problems because load_rails was misleading and actually only loaded your models and ActiveRecord, I have just pushed a small update> All that has changed is that in the config file load_rails is set to true by default and it actually loads all of rails by require'ing environment.rb. SO anything that works in your rails app should be available in your workers now including plugins and engines. Sorry for the confustion that was a seriously bad choice of a config option for what it used to do. Nothing else has changed sine the last release except for this. Thanks- -Ezra From ezmobius at gmail.com Fri Aug 25 11:46:21 2006 From: ezmobius at gmail.com (Ezra Zygmuntowicz) Date: Fri, 25 Aug 2006 08:46:21 -0700 Subject: [Backgroundrb-devel] backgroundrb fails when running as win32 service In-Reply-To: <44EE88E1.1060009@magian.com> References: <44EE88E1.1060009@magian.com> Message-ID: On Aug 24, 2006, at 10:21 PM, Daniel Greig wrote: > Hi, > I've been playing with backgroundrb to batch process a bunch of images > on a rails server. The process is working fine when backgroundrb is > started from the command line, but seems to choke occasionally (well, > quite often) when running as a service. It seems to get stuck on the > following line when moving files: > FileUtils.move(src, dest, :verbose => true) > > with the error: > > Bad file descriptor - (Errno::EBADF) > > For a while I thought it may have been a file permissions/file access > issue, but I have seen another error where the process fails at a > "puts" > statement. I have a suspicion that the error may be occurring when > ruby > tries to write to the standard output using "puts". Since the > "verbose" > argument sends a message to the standard output, it could be failing > for the same reason and just looking like a file move error. > I have removed all puts statements and all verbose method calls and > the > service *seems* to be more reliable (although it's to early to say > as I > have to do a lot more testing). Has anyone seen any similar problems > with the win32 service? > > My fingers are crossed that getting rid of the puts statements > fixes the > problem, but I'm nervous that it may be something else entirely - > anyone > have any ideas? > thanks! > Dan Hey Dan- Unfortunately I don't have any windows boxes for testing the service part with. But from what I know of windows services you are correct, I think the errors you are getting are from using puts or print to stdout which seems to be closed or unavailable when running as a service. So as long as you don't use puts or print and instead use the @logger you should be fine. I also wonder if there is a way to redirect stdout to the log file on windows? If you get a chance to investigate then please let me know what you find out. For now you will probably have to not use the verbose option and make sure you use the log instead of puts. Cheers- -Ezra From gethemant at gmail.com Fri Aug 25 16:14:09 2006 From: gethemant at gmail.com (hemant) Date: Sat, 26 Aug 2006 01:44:09 +0530 Subject: [Backgroundrb-devel] uninitialised constant LoginEngine In-Reply-To: <1C459FFB-2FF5-4F88-9DA3-EDFF93EEC14C@brainspl.at> References: <1C459FFB-2FF5-4F88-9DA3-EDFF93EEC14C@brainspl.at> Message-ID: Again i managed to workaround the problem, by simply not using user.rbfiles(model class defined by LoginEngine). :) but...i had another issue, some of my model classes, were using some global connection objects( not to databases but Unix socket connections to some data vending servers).Now, this connection object was created in environment.rb file, so i required the file in that worker thread and it started to work. but, isn't it that loading the entire rails environment is a little heavy?? On 8/25/06, Ezra Zygmuntowicz wrote: > > > On Aug 25, 2006, at 4:39 AM, hemant wrote: > > > I geuss, I am the one, who is asking this question again.I tried to > > search through, the mails, but clearly...following solutions didn't > > work for me: > > > > $: << "#{RAILS_ROOT}/vendor/plugins/engines/lib/engines" > > $: << "#{RAILS_ROOT}/vendor/plugins/login_engine/lib" > > > > Also, i last time, I worked around the problem by simply not using > > loginengine model class.But this time, as it seems i need this. > > There is a price to be paid, for using some readymade component. > > > > > > > > _______________________________________________ > > Backgroundrb-devel mailing list > > Backgroundrb-devel at rubyforge.org > > http://rubyforge.org/mailman/listinfo/backgroundrb-devel > > Hey Hemant- > > What I think you need to do is open up the start script and > replace > the line that require's boot.rb and make it require environment.rb., > THat way it will go through rails normal load process and your > engines will get loaded as well. > > This has bitten enough people that I am going to change it so that > by default it will require all of rails if you set load_rails to true > in your config file. Its an inconosistency on my part the way it > works now. > > Cheers- > -Ezra > -- nothing much to talk -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060826/5323936b/attachment.html From hughes.james at gmail.com Fri Aug 25 17:22:27 2006 From: hughes.james at gmail.com (James Hughes) Date: Fri, 25 Aug 2006 14:22:27 -0700 Subject: [Backgroundrb-devel] Rake tasks fail silently, how to debug? Message-ID: <765a2c230608251422j4d3bba9bx91aa0650a7abdd88@mail.gmail.com> Hi, I've been using backgroundrb with some success up to now, but now when I do the start or setup tasks they just fail silently. Nothing in the log, no .pid file, and nothing in the process list. Rake with -trace just says, ** Invoke backgroundrb:setup (first_time) ** Execute backgroundrb:setup Any hints on how I can get more verbosity, or thoughts on what might be happening? (This happens with both the rails gem and edge; also, I'm tracking backgroundrb via svn:externals) thanks, jh -- James Hughes Web application developer Vancouver, BC "Developing a coherent political analysis is in many respects contingent upon an ability to connect one context to another, a process not dissimilar to playing the kid's game of dot-to-dot." - Ward Churchill, from '"A Government of Laws"?' From ezmobius at gmail.com Fri Aug 25 17:33:51 2006 From: ezmobius at gmail.com (Ezra Zygmuntowicz) Date: Fri, 25 Aug 2006 14:33:51 -0700 Subject: [Backgroundrb-devel] Rake tasks fail silently, how to debug? In-Reply-To: <765a2c230608251422j4d3bba9bx91aa0650a7abdd88@mail.gmail.com> References: <765a2c230608251422j4d3bba9bx91aa0650a7abdd88@mail.gmail.com> Message-ID: <1F6E85D2-E1C7-4EBD-9CB4-84AE7AE4A7D6@gmail.com> On Aug 25, 2006, at 2:22 PM, James Hughes wrote: > Hi, > > I've been using backgroundrb with some success up to now, but now when > I do the start or setup tasks they just fail silently. Nothing in the > log, no .pid file, and nothing in the process list. Rake with -trace > just says, > > ** Invoke backgroundrb:setup (first_time) > ** Execute backgroundrb:setup > > Any hints on how I can get more verbosity, or thoughts on what might > be happening? > > (This happens with both the rails gem and edge; also, I'm tracking > backgroundrb via svn:externals) > > thanks, > jh > > -- > James Hughes > Web application developer > Vancouver, BC Hey James- When did this start happening? If you roll back one revision from trunk does that fix it? I just did a fresh svn co of trunk and was able to run the setup and start tasks without any issues. So please try again. Aslo can you use the start script directly instead of the rake task? Take a look in the rake task you can see what it does, it just copies the script dir up into your rails app and makes a config file. I don't know how to make rake more verbose in this case. Maybe open up the rakefile and add some puts statements and tell me what you find out would you? -Ezra From hughes.james at gmail.com Fri Aug 25 18:09:57 2006 From: hughes.james at gmail.com (James Hughes) Date: Fri, 25 Aug 2006 15:09:57 -0700 Subject: [Backgroundrb-devel] Rake tasks fail silently, how to debug? In-Reply-To: <1F6E85D2-E1C7-4EBD-9CB4-84AE7AE4A7D6@gmail.com> References: <765a2c230608251422j4d3bba9bx91aa0650a7abdd88@mail.gmail.com> <1F6E85D2-E1C7-4EBD-9CB4-84AE7AE4A7D6@gmail.com> Message-ID: <765a2c230608251509j4df07920v11d791f18e269708@mail.gmail.com> (Sorry, I keep forgetting reply-all on this list) On 8/25/06, Ezra Zygmuntowicz wrote: > > On Aug 25, 2006, at 2:22 PM, James Hughes wrote: > > > Any hints on how I can get more verbosity, or thoughts on what might > > be happening? > > > > (This happens with both the rails gem and edge; also, I'm tracking > > backgroundrb via svn:externals) > > Hey James- > > When did this start happening? If you roll back one revision from > trunk does that fix it? I just did a fresh svn co of trunk and was > able to run the setup and start tasks without any issues. So please > try again. Aslo can you use the start script directly instead of the > rake task? Take a look in the rake task you can see what it does, it > just copies the script dir up into your rails app and makes a config > file. I don't know how to make rake more verbose in this case. Maybe > open up the rakefile and add some puts statements and tell me what > you find out would you? > > -Ezra > Hi Ezra, I've done what you suggest. The setup task actually appears to be behaving correctly: all the scripts and config are already in place so it's not actually failing, it's just not doing anything. However, when I run the start script directly (i.e. not with rake), without the -d option, I get the following: /home/jhughes/work/media-catalog/trunk/config/../script/backgroundrb/start:99: private method `new' called for BackgrounDRb::MiddleMan:Class (NoMethodError). Something's not where it's supposed to be, but I'm not sure what. jh ps. Also possibly relevant, when I run the tests I get the following failure: 1) Failure: test_new_worker(BackgrounDRbTest) [./test/test_backgroundrb.rb:43]: expected to be kind_of? but was . -- James Hughes Web application developer Vancouver, BC "Developing a coherent political analysis is in many respects contingent upon an ability to connect one context to another, a process not dissimilar to playing the kid's game of dot-to-dot." - Ward Churchill, from '"A Government of Laws"?' From ezmobius at gmail.com Fri Aug 25 19:04:59 2006 From: ezmobius at gmail.com (Ezra Zygmuntowicz) Date: Fri, 25 Aug 2006 16:04:59 -0700 Subject: [Backgroundrb-devel] Rake tasks fail silently, how to debug? In-Reply-To: <765a2c230608251509j4df07920v11d791f18e269708@mail.gmail.com> References: <765a2c230608251422j4d3bba9bx91aa0650a7abdd88@mail.gmail.com> <1F6E85D2-E1C7-4EBD-9CB4-84AE7AE4A7D6@gmail.com> <765a2c230608251509j4df07920v11d791f18e269708@mail.gmail.com> Message-ID: On Aug 25, 2006, at 3:09 PM, James Hughes wrote: > (Sorry, I keep forgetting reply-all on this list) > > On 8/25/06, Ezra Zygmuntowicz wrote: >> >> On Aug 25, 2006, at 2:22 PM, James Hughes wrote: >> >>> Any hints on how I can get more verbosity, or thoughts on what might >>> be happening? >>> >>> (This happens with both the rails gem and edge; also, I'm tracking >>> backgroundrb via svn:externals) >> >> Hey James- >> >> When did this start happening? If you roll back one >> revision from >> trunk does that fix it? I just did a fresh svn co of trunk and was >> able to run the setup and start tasks without any issues. So please >> try again. Aslo can you use the start script directly instead of the >> rake task? Take a look in the rake task you can see what it does, it >> just copies the script dir up into your rails app and makes a config >> file. I don't know how to make rake more verbose in this case. Maybe >> open up the rakefile and add some puts statements and tell me what >> you find out would you? >> >> -Ezra >> > > Hi Ezra, > > I've done what you suggest. The setup task actually appears to be > behaving correctly: all the scripts and config are already in place so > it's not actually failing, it's just not doing anything. However, when > I run the start script directly (i.e. not with rake), without the -d > option, I get the following: > > /home/jhughes/work/media-catalog/trunk/config/../script/ > backgroundrb/start:99: > private method `new' called for BackgrounDRb::MiddleMan:Class > (NoMethodError). > > Something's not where it's supposed to be, but I'm not sure what. > jh > > ps. Also possibly relevant, when I run the tests I get the > following failure: > > 1) Failure: > test_new_worker(BackgrounDRbTest) [./test/test_backgroundrb.rb:43]: > > expected to be kind_of? > but was > . Hey James- I think that somehow you are getting a few versions mixed up. I recently made the MiddleMan class be a singleton so that accounts for the error of private method new . I think what you should do is remove all traces of the plugin from your app. Except you can leave your workers in lib/workers. But remove everything esle , the plugin the config file and the script/backgroundrb dir from your rails app. Then reinstall the plugin from trunk and rerun the setup task and try again. I think that should fix the problem. It seems like you may have parts of two different versions installed and that is what is causing the errors. Cheers- -Ezra From hughes.james at gmail.com Fri Aug 25 19:08:13 2006 From: hughes.james at gmail.com (James Hughes) Date: Fri, 25 Aug 2006 16:08:13 -0700 Subject: [Backgroundrb-devel] Rake tasks fail silently, how to debug? In-Reply-To: <765a2c230608251509j4df07920v11d791f18e269708@mail.gmail.com> References: <765a2c230608251422j4d3bba9bx91aa0650a7abdd88@mail.gmail.com> <1F6E85D2-E1C7-4EBD-9CB4-84AE7AE4A7D6@gmail.com> <765a2c230608251509j4df07920v11d791f18e269708@mail.gmail.com> Message-ID: <765a2c230608251608l3f2ad80dv2f14faa77772850@mail.gmail.com> > > /home/jhughes/work/media-catalog/trunk/config/../script/backgroundrb/start:99: > private method `new' called for BackgrounDRb::MiddleMan:Class > (NoMethodError). Ok, above was due to old start/stop scripts lying around in rails' script directory. I didn't realize you have to clobber the entire script/backgroundrb directory in order for setup to recopy these. thanks, jh -- James Hughes Web application developer Vancouver, BC "Developing a coherent political analysis is in many respects contingent upon an ability to connect one context to another, a process not dissimilar to playing the kid's game of dot-to-dot." - Ward Churchill, from '"A Government of Laws"?' From lists at foorama.com Fri Aug 25 23:13:08 2006 From: lists at foorama.com (Tim Trautmann) Date: Fri, 25 Aug 2006 20:13:08 -0700 Subject: [Backgroundrb-devel] postgres-pr barfs at ActiveRecord::Base.allow_concurrency = true Message-ID: Hi List, first of thank you Ezra for BackgroundRB. Very cool plugin indeed! This is a public service FYI. In case you are running postgres as your database backend and you are seeing the following errors in your backgroundrb.log: ActiveRecord::StatementInvalid: NoMethodError: undefined method `async_query' for #: You are using the postgres-pr adapter which does not seem to support async_query. You need to install the compiled postgres db adapter wich can be found here: http://rubyforge.org/projects/ruby-postgres/ Or alternatively you could set ActiveRecord::Base.allow_concurrency to "false" in your backgroundrb start script. Though this could have adverse side effects. Thought this might be helpful to others in the future. Best, Tim From vicente.reig at gmail.com Sat Aug 26 13:55:45 2006 From: vicente.reig at gmail.com (Vicente Reig) Date: Sat, 26 Aug 2006 19:55:45 +0200 Subject: [Backgroundrb-devel] Dreamhost issues Message-ID: <835d58c60608261055k15e8eb64q522e47073a7dfc@mail.gmail.com> Hi there! I just have discovered this wonderful plugin a few days ago and I uploaded a little test to my Dreamhost account. I simply got a worker that resizes an image that the user uploads. So this morning I launched the BackgrounDRb server on my account with the rake task and began to upload some test images. The server daemon has been executing until a few minutes ago, I suppose because of Dreamhost's watchdog that killed the process. So my RoR application could be capable of restarting the server if it detects that is down, right? I mean that I think I can code it, but I would like to hear someone's else experience or if it's just a crazy idea :-) I know I could put a spinner near the file_field until the image gets resized and forget about the Workers... but I like the idea of the web application doing some work behind the scenes. If anyone cares, I'm coding a flickr-like application for fun and for my sister's wedding. :-) -- Vicente Reig Rinc?n de Arellano http://www.vicentereig.info/ mvl: 679 980 411 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060826/92afc758/attachment.html From mklein at bpl.org Sun Aug 27 20:52:21 2006 From: mklein at bpl.org (Klein, Michael) Date: Sun, 27 Aug 2006 20:52:21 -0400 Subject: [Backgroundrb-devel] Dreamhost issues References: <835d58c60608261055k15e8eb64q522e47073a7dfc@mail.gmail.com> Message-ID: An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060827/3c937681/attachment.html From bjohnson at contuitive.com Mon Aug 28 03:02:17 2006 From: bjohnson at contuitive.com (Ben Johnson) Date: Mon, 28 Aug 2006 02:02:17 -0500 Subject: [Backgroundrb-devel] Just a tip Message-ID: I figured instead of asking a question I would share some useful knowledge I learned this week. Maybe you already know this, maybe you dont. If you use backgroundrb to run an "infinite" loop, or create many threads, or do quite a bit of processor intensive tasks, and you notice that its running kind of slow, it might not be a bad idea to have multiple backgroundrb processes running, especially if you have a dual core processor or more than 1 processor. I am on a server with 2 dual core processors. I noticed under the "top" command my background process was reaching 99% of the CPU. This was because it was only utilizing 1/4 of the power the server had to offer. Anyways, I modified backgroundrb quite a bit. To the point where I can make a change in the configuration file and allow the start script to create as many processes as I need. Needless to say I saw speed increases of over 10 times what it used to be. All that you have to do is evenly distribute your tasks among the many processes. Maybe this will help someone, who know, but its worth putting into this list. Thank You, Ben Johnson E: bjohnson at contuitive.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060828/7330b756/attachment.html From ezmobius at gmail.com Mon Aug 28 03:28:05 2006 From: ezmobius at gmail.com (Ezra Zygmuntowicz) Date: Mon, 28 Aug 2006 00:28:05 -0700 Subject: [Backgroundrb-devel] Just a tip In-Reply-To: References: Message-ID: <56C58C88-0108-455B-A0FF-77744E4D997D@gmail.com> On Aug 28, 2006, at 12:02 AM, Ben Johnson wrote: > I figured instead of asking a question I would share some useful > knowledge I learned this week. Maybe you already know this, maybe > you dont. > > If you use backgroundrb to run an "infinite" loop, or create many > threads, or do quite a bit of processor intensive tasks, and you > notice that its running kind of slow, it might not be a bad idea to > have multiple backgroundrb processes running, especially if you > have a dual core processor or more than 1 processor. I am on a > server with 2 dual core processors. I noticed under the "top" > command my background process was reaching 99% of the CPU. This was > because it was only utilizing 1/4 of the power the server had to > offer. Anyways, I modified backgroundrb quite a bit. To the point > where I can make a change in the configuration file and allow the > start script to create as many processes as I need. > > Needless to say I saw speed increases of over 10 times what it used > to be. > > All that you have to do is evenly distribute your tasks among the > many processes. > > Maybe this will help someone, who know, but its worth putting into > this list. > > Thank You, > Ben Johnson > E: bjohnson at contuitive.com > > Hey Ben- Care to share your enhancements? -Ezra -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060828/e1744247/attachment-0001.html From martin at nosleepmedia.com Mon Aug 28 21:21:05 2006 From: martin at nosleepmedia.com (Martin May) Date: Mon, 28 Aug 2006 19:21:05 -0600 Subject: [Backgroundrb-devel] Tasks get executed twice with repeat_every Message-ID: <21F9013A-C945-495D-9ED1-83675F7C7ABF@nosleepmedia.com> I have a simple worker that I set up with repeat_every: class DueNoteQueuerWorker < BackgrounDRb::Rails repeat_every 1.minutes first_run Time.now def do_work(args) @logger.debug("Sending due notes. The current time is #{Time.now}") end end I want this to run every minute, all the time. The first run is fine, but it seems that subsequent runs get executed twice. From the logfile: # Logfile created on Mon Aug 28 19:18:01 MDT 2006 by logger.rb/1.5.2.7 Sending due notes. The current time is Mon Aug 28 19:18:03 MDT 2006 Sending due notes. The current time is Mon Aug 28 19:19:03 MDT 2006 Sending due notes. The current time is Mon Aug 28 19:19:03 MDT 2006 Sending due notes. The current time is Mon Aug 28 19:20:03 MDT 2006 Sending due notes. The current time is Mon Aug 28 19:20:03 MDT 2006 Is there any way to fix that? Here is my configuration file: --- port: "22222" timer_sleep: 60 load_rails: true environment: development host: localhost database_yml: config/database.yml acl: deny: all allow: localhost 127.0.0.1 order: deny,allow autostart: 1: job_key: due_note_queuer1 class: due_note_queuer_worker Thanks, Martin From ezmobius at gmail.com Tue Aug 29 14:40:43 2006 From: ezmobius at gmail.com (Ezra Zygmuntowicz) Date: Tue, 29 Aug 2006 11:40:43 -0700 Subject: [Backgroundrb-devel] Tasks get executed twice with repeat_every In-Reply-To: <21F9013A-C945-495D-9ED1-83675F7C7ABF@nosleepmedia.com> References: <21F9013A-C945-495D-9ED1-83675F7C7ABF@nosleepmedia.com> Message-ID: <1350A024-E359-422B-814B-506523019813@gmail.com> Hi~ On Aug 28, 2006, at 6:21 PM, Martin May wrote: > > I have a simple worker that I set up with repeat_every: > > class DueNoteQueuerWorker < BackgrounDRb::Rails > > repeat_every 1.minutes > first_run Time.now > > def do_work(args) > @logger.debug("Sending due notes. The current time is # > {Time.now}") > end > > end > > > I want this to run every minute, all the time. The first run is fine, > but it seems that subsequent runs get executed twice. From the > logfile: > > # Logfile created on Mon Aug 28 19:18:01 MDT 2006 by logger.rb/1.5.2.7 > Sending due notes. The current time is Mon Aug 28 19:18:03 MDT 2006 > Sending due notes. The current time is Mon Aug 28 19:19:03 MDT 2006 > Sending due notes. The current time is Mon Aug 28 19:19:03 MDT 2006 > Sending due notes. The current time is Mon Aug 28 19:20:03 MDT 2006 > Sending due notes. The current time is Mon Aug 28 19:20:03 MDT 2006 > > Is there any way to fix that? Here is my configuration file: > > --- > port: "22222" > timer_sleep: 60 > load_rails: true > environment: development > host: localhost > database_yml: config/database.yml > acl: > deny: all > allow: localhost 127.0.0.1 > order: deny,allow > autostart: > 1: > job_key: due_note_queuer1 > class: due_note_queuer_worker > > Thanks, > Martin Hey Martin- I am working on rewriting the timing mechanism for cron like workers. I had one other person report a similar issue when one worker is still running and the next one kicks off. So for now you can either try to patch it yourself or wait a bit longer until the next release. Cheers- -Ezra From ezmobius at gmail.com Tue Aug 29 14:43:17 2006 From: ezmobius at gmail.com (Ezra Zygmuntowicz) Date: Tue, 29 Aug 2006 11:43:17 -0700 Subject: [Backgroundrb-devel] Dreamhost issues In-Reply-To: References: <835d58c60608261055k15e8eb64q522e47073a7dfc@mail.gmail.com> Message-ID: <08EA73D3-1B96-4082-8D24-5E07492F3747@gmail.com> Hmm yeah that sucks. Dreamhost is know for killing long running tasks. There is a frao handler someone made for fcgi so that when dreamhost tries to tell your fcgi's to die, they will just trap the kill signal and continue on running. It is possible to use this technique with bgdrb. I am busy this week setting up engine yard but next week when I get back home I could try to add something to handle this so it doesn't get killed off. Cheers- -Ezra On Aug 27, 2006, at 5:52 PM, Klein, Michael wrote: > I use RoR/BackgrounDRb on Dreamhost, and I do just what you're > saying -- if I get an "unable to connect" error from the MiddleMan, > I restart the server and retry. After 3 failed retries, I bubble > the exception up. > > Ezra -- is there a way to code this (optional, obviously) autostart > behavior into the MiddleMan class itself? I can never remember > whether the MiddleMan is local and the workers remote, or whether > the MiddleMan itself is undumped. > > Michael > > > -----Original Message----- > From: backgroundrb-devel-bounces at rubyforge.org on behalf of Vicente > Reig > Sent: Sat 8/26/2006 1:55 PM > To: backgroundrb-devel at rubyforge.org > Subject: [Backgroundrb-devel] Dreamhost issues > > Hi there! > I just have discovered this wonderful plugin a few days ago and I > uploaded a > little test to my Dreamhost account. I simply got a worker that > resizes an > image that the user uploads. > So this morning I launched the BackgrounDRb server on my account > with the > rake task and began to upload some test images. The server daemon > has been > executing until a few minutes ago, I suppose because of Dreamhost's > watchdog > that killed the process. So my RoR application could be capable of > restarting the server if it detects that is down, right? I mean > that I think > I can code it, but I would like to hear someone's else experience > or if it's > just a crazy idea :-) > > I know I could put a spinner near the file_field until the image gets > resized and forget about the Workers... but I like the idea of the web > application doing some work behind the scenes. > > If anyone cares, I'm coding a flickr-like application for fun and > for my > sister's wedding. :-) > > -- > Vicente Reig Rinc?n de Arellano > http://www.vicentereig.info/ > mvl: 679 980 411 > > > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060829/f74063e2/attachment.html From martin at nosleepmedia.com Tue Aug 29 14:55:00 2006 From: martin at nosleepmedia.com (Martin May) Date: Tue, 29 Aug 2006 12:55:00 -0600 Subject: [Backgroundrb-devel] Environment Setting Message-ID: <86AB824A-0C8D-4FB8-99D9-00988177E0E9@nosleepmedia.com> Looks like the environment setting isn't being applied, it always starts up in development mode for me. Could this have something to do with the recent change to loading the full Rails environment? Martin