From g.h.vandoorn at gmail.com Sun Oct 4 03:01:07 2009 From: g.h.vandoorn at gmail.com (Gerrit Hendrikus van Doorn) Date: Sun, 4 Oct 2009 00:01:07 -0700 Subject: [Backgroundrb-devel] BackgroundRB 1.0.4 on Windows Message-ID: <1e36695b0910040001x36178250q57c8d436c92e8dda@mail.gmail.com> Hi, I'm trying to run BackgroundRB 1.0.4 on windows. I installed win32-process and windows-pr and it seems to start. However, after about 10 seconds I notice that the ruby processes exit and leave me with the following error: process.rb:302:in `kill': The parameter is incorrect. (Process::Error) from C:/Ruby/lib/ruby/gems/1.8/gems/win32-process-0.6.1/lib/win32/process.rb:278:in `each' from C:/Ruby/lib/ruby/gems/1.8/gems/win32-process-0.6.1/lib/win32/process.rb:278:in `kill' from C:/Documents and Settings/me/My Documents/Aptana Studio Workspace/project/vendor/plugins/backgroundrb/lib/backgroundrb/bdr b_start_stop.rb:20:in `really_running?' from C:/Documents and Settings/me/My Documents/Aptana Studio Workspace/project/vendor/plugins/backgroundrb/lib/backgroundrb/bdr b_start_stop.rb:31:in `try_restart' from C:/Documents and Settings/me/My Documents/Aptana Studio Workspace/project/vendor/plugins/backgroundrb/lib/backgroundrb/bdr b_start_stop.rb:42:in `start' from C:/Documents and Settings/me/My Documents/Aptana Studio Workspace/project/script/backgroundrb:35 Is it possible to run Backgroundrb on windows? If so, what am I doing wrong? Thanks, Gerwin -- g.h.vandoorn at gmail.com +1.510.859.4618 -------------- next part -------------- An HTML attachment was scrubbed... URL: From flavio at castelli.name Wed Oct 7 13:38:15 2009 From: flavio at castelli.name (Flavio Castelli) Date: Wed, 7 Oct 2009 19:38:15 +0200 Subject: [Backgroundrb-devel] Questions raised during the upgrade to the latest backgroundrb Message-ID: I'm upgrading my code to the latest version of backgroundrb. I was still running a really old version of backgroundrb. I have created a FooWorker class which inherits BackgrounDRb::MetaWorker. I instantiate it in this way: MiddleMan.new_worker(:worker => :foo_worker, :worker_key => key, :data => args) Then I start the background job in this way: @job = MiddleMan.worker( :foo_worker, key) @job.async_really_long_job Everything is working fine but I've some questions: How can I retrieve the instance of the running job from other parts of the code? How can I get the "start_time" attribute? I have tried to to access the trigger attribute of MetaWorker but it doesn't reply (I waited some minutes than I interrupted irb). Thanks in advance Flavio From g.h.vandoorn at gmail.com Wed Oct 7 14:47:50 2009 From: g.h.vandoorn at gmail.com (Gerrit Hendrikus van Doorn) Date: Wed, 7 Oct 2009 11:47:50 -0700 Subject: [Backgroundrb-devel] Is it possible to run BackgroundRB in cygwin and connect in Windows? Message-ID: <1e36695b0910071147i49c1e3ces9fd2e36acaf4c15a@mail.gmail.com> Hi, I got BackgroundRB to start under cygwin (currently using the version from GIT) but when starting it I get the errors shown at the bottom of this message. Is it possible to run this cygwin+windows combination? What do the errors mean? /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- log_worker (LoadError) from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from /usr/lib/ruby/gems/1.8/gems/packet-0.1.15/bin/packet_worker_runner:35:in `load_worker' from /usr/lib/ruby/gems/1.8/gems/packet-0.1.15/bin/packet_worker_runner:26:in `initialize' from /usr/lib/ruby/gems/1.8/gems/packet-0.1.15/bin/packet_worker_runner:47:in `new' from /usr/lib/ruby/gems/1.8/gems/packet-0.1.15/bin/packet_worker_runner:47 from /usr/bin/packet_worker_runner:19:in `load' from /usr/bin/packet_worker_runner:19 /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- flickr_worker (LoadError) from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from /usr/lib/ruby/gems/1.8/gems/packet-0.1.15/bin/packet_worker_runner:35:in `load_worker' from /usr/lib/ruby/gems/1.8/gems/packet-0.1.15/bin/packet_worker_runner:26:in `initialize' from /usr/lib/ruby/gems/1.8/gems/packet-0.1.15/bin/packet_worker_runner:47:in `new' from /usr/lib/ruby/gems/1.8/gems/packet-0.1.15/bin/packet_worker_runner:47 from /usr/bin/packet_worker_runner:19:in `load' from /usr/bin/packet_worker_runner:19 Ignoring the above errors and calling a method from my worker flickr_worker gives me the following error: # /cygdrive/c/Documents and Settings/me/My Documents/Aptana Studio Workspace/MyProject/vendor/plugins/backgroundrb/server/lib/master_worker.rb:129:in `worker_methods' /cygdrive/c/Documents and Settings/me/My Documents/Aptana Studio Workspace/MyProject/vendor/plugins/backgroundrb/server/lib/master_worker.rb:107:in `async_method_invoke' /cygdrive/c/Documents and Settings/me/My Documents/Aptana Studio Workspace/MyProject/vendor/plugins/backgroundrb/server/lib/master_worker.rb:38:in `receive_data' /usr/lib/ruby/gems/1.8/gems/packet-0.1.15/lib/packet/packet_parser.rb:44:in `extract' /usr/lib/ruby/gems/1.8/gems/packet-0.1.15/lib/packet/packet_parser.rb:26:in `loop' /usr/lib/ruby/gems/1.8/gems/packet-0.1.15/lib/packet/packet_parser.rb:26:in `extract' /cygdrive/c/Documents and Settings/me/My Documents/Aptana Studio Workspace/MyProject/vendor/plugins/backgroundrb/server/lib/master_worker.rb:32:in `receive_data' /usr/lib/ruby/gems/1.8/gems/packet-0.1.15/lib/packet/packet_core.rb:230:in `read_external_socket' /usr/lib/ruby/gems/1.8/gems/packet-0.1.15/lib/packet/packet_core.rb:222:in `handle_external_messages' /usr/lib/ruby/gems/1.8/gems/packet-0.1.15/lib/packet/packet_core.rb:196:in `handle_read_event' /usr/lib/ruby/gems/1.8/gems/packet-0.1.15/lib/packet/packet_core.rb:192:in `each' /usr/lib/ruby/gems/1.8/gems/packet-0.1.15/lib/packet/packet_core.rb:192:in `handle_read_event' /usr/lib/ruby/gems/1.8/gems/packet-0.1.15/lib/packet/packet_core.rb:146:in `start_reactor' /usr/lib/ruby/gems/1.8/gems/packet-0.1.15/lib/packet/packet_core.rb:139:in `loop' /usr/lib/ruby/gems/1.8/gems/packet-0.1.15/lib/packet/packet_core.rb:139:in `start_reactor' /usr/lib/ruby/gems/1.8/gems/packet-0.1.15/lib/packet/packet_master.rb:21:in `run' /cygdrive/c/Documents and Settings/me/My Documents/Aptana Studio Workspace/MyProject/vendor/plugins/backgroundrb/server/lib/master_proxy.rb:14:in `initialize' /cygdrive/c/Documents and Settings/me/My Documents/Aptana Studio Workspace/MyProject/vendor/plugins/backgroundrb/lib/backgroundrb/bdrb_start_stop.rb:109:in `new' /cygdrive/c/Documents and Settings/me/My Documents/Aptana Studio Workspace/MyProject/vendor/plugins/backgroundrb/lib/backgroundrb/bdrb_start_stop.rb:109:in `start_bdrb' /cygdrive/c/Documents and Settings/me/My Documents/Aptana Studio Workspace/MyProject/vendor/plugins/backgroundrb/lib/backgroundrb/bdrb_start_stop.rb:16:in `start' script/backgroundrb:35 -- g.h.vandoorn at gmail.com +1.510.859.4618 -------------- next part -------------- An HTML attachment was scrubbed... URL: From toastkid.williams at gmail.com Wed Oct 14 04:17:48 2009 From: toastkid.williams at gmail.com (Max Williams) Date: Wed, 14 Oct 2009 09:17:48 +0100 Subject: [Backgroundrb-devel] backgroundrb noob question In-Reply-To: References: Message-ID: I'm a bit of a backgroundrb noob, though i do use it for several different things. I usually follow the paradigm of keeping the controller code as similar as possible, but instead of calling the original model method, calling a new model method which calls a backgroundrb task, which in turn calls the *original* model method. eg instead of this -controller calls 'my_obj.do_heavy_lifting' -instance method do_heavy_lifting runs and returns -controller continues I do this - controller calls 'my_obj.background_do_heavy_lifting' - instance method background_do_heavy_lifting runs:it just calls a worker method and returns - controller continues - worker method (in the background) calls 'my_obj.do_heavy_lifting' -instance method do_heavy_lifting runs (in the background) and returns Of course this assumes that do_heavy_lifting can be done asynchronously, ie that the controller can carry on without waiting for it to finish. But i assume that's the case because otherwise why use backgroundrb? BTW your code for adding a record to the database is kind of horrible and very error prone - why can't you use AR::Base.create? 2009/10/14 Chris Sund > Hey Everyone, > > I'm trying to get backgroundrb running and I would consider myself an > intermediate rails programmer. I have the following controller method that I > would like to move to a worker method, but I'm not sure how to properly call > it from my controller once I place it in the worker method. Any advice or > help would be appreciated. Due to the fact I am still learning, code > examples would be awesome, but not necessary. I can usually get things > figured out given enough time. > > Thanks! > > Chris > > > def download_reads > > if fields_mapped? > mapped_fields.each do |row| > > ActiveRecord::Base.connection.execute( > "insert into readings(reading, > date, > year, > accounting_period, > account_id, > water_usage, > created_at, > updated_at) > values ('#{row[0]}', > '#{row[1]}', > '#{row[2]}', > '#{row[3]}', > '#{row[4]}', > '#{row[5]}', > '#{Time.current.to_s(:db)}', > '#{Time.current.to_s(:db)}');") > > end > flash[:notice] = 'Water Readings Have Been Downloaded' > redirect_to :action => :download > else > > end > rescue MapFields::InconsistentStateError > flash[:error] = 'Please try again' > redirect_to :action => :download > rescue MapFields::MissingFileContentsError > flash[:error] = 'Please upload a file' > redirect_to :action => :download > > end > > > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel > -------------- next part -------------- An HTML attachment was scrubbed... URL: From toastkid.williams at gmail.com Wed Oct 14 10:06:29 2009 From: toastkid.williams at gmail.com (Max Williams) Date: Wed, 14 Oct 2009 15:06:29 +0100 Subject: [Backgroundrb-devel] backgroundrb noob question In-Reply-To: References: Message-ID: ah yeah, big imports from text files do take forever if you use AR, don't they. I never use worker_new, i always just say something like result = MiddleMan.worker(:lmail_worker).enq_mail_confirmation_letters(:arg => {:user_ids => users.collect(&:id), :password => password, :options => options}, :job_key => job_key) 2009/10/14 Chris Sund > Hey Max, > > Thanks for the reply. I want to move this back to AR that's why I want to > implement backgroundrb. This process can take up to 29 minutes using Active > Record where if I do straight SQL inserts it's a 2 minute process. I'm > importing about 200K records at a time. I don't like programming outside > the box though and the downside is I loose the ability to do validations and > other nifty AR functions which I think is more useful than the time issue. > In any case I had another question... > > 1.) What is the difference between MiddleMan.worker & Middleman.worker_new > ? This is my biggest hang up. I'm not sure how to call the worker > appropriately so it will create a session and fire my function > > Thanks! > > Chris > > > On Wed, Oct 14, 2009 at 2:17 AM, Max Williams > wrote: > >> I'm a bit of a backgroundrb noob, though i do use it for several different >> things. I usually follow the paradigm of keeping the controller code as >> similar as possible, but instead of calling the original model method, >> calling a new model method which calls a backgroundrb task, which in turn >> calls the *original* model method. eg instead of this >> >> -controller calls 'my_obj.do_heavy_lifting' >> -instance method do_heavy_lifting runs and returns >> -controller continues >> >> I do this >> >> - controller calls 'my_obj.background_do_heavy_lifting' >> - instance method background_do_heavy_lifting runs:it just calls a worker >> method and returns >> - controller continues >> - worker method (in the background) calls 'my_obj.do_heavy_lifting' >> -instance method do_heavy_lifting runs (in the background) and returns >> >> Of course this assumes that do_heavy_lifting can be done asynchronously, >> ie that the controller can carry on without waiting for it to finish. But i >> assume that's the case because otherwise why use backgroundrb? >> >> BTW your code for adding a record to the database is kind of horrible and >> very error prone - why can't you use AR::Base.create? >> >> >> 2009/10/14 Chris Sund >> >>> Hey Everyone, >>> >>> I'm trying to get backgroundrb running and I would consider myself an >>> intermediate rails programmer. I have the following controller method that I >>> would like to move to a worker method, but I'm not sure how to properly call >>> it from my controller once I place it in the worker method. Any advice or >>> help would be appreciated. Due to the fact I am still learning, code >>> examples would be awesome, but not necessary. I can usually get things >>> figured out given enough time. >>> >>> Thanks! >>> >>> Chris >>> >>> >>> def download_reads >>> >>> if fields_mapped? >>> mapped_fields.each do |row| >>> >>> ActiveRecord::Base.connection.execute( >>> "insert into readings(reading, >>> date, >>> year, >>> accounting_period, >>> account_id, >>> water_usage, >>> created_at, >>> updated_at) >>> values ('#{row[0]}', >>> '#{row[1]}', >>> '#{row[2]}', >>> '#{row[3]}', >>> '#{row[4]}', >>> '#{row[5]}', >>> '#{Time.current.to_s(:db)}', >>> '#{Time.current.to_s(:db)}');") >>> >>> end >>> flash[:notice] = 'Water Readings Have Been Downloaded' >>> redirect_to :action => :download >>> else >>> >>> end >>> rescue MapFields::InconsistentStateError >>> flash[:error] = 'Please try again' >>> redirect_to :action => :download >>> rescue MapFields::MissingFileContentsError >>> flash[:error] = 'Please upload a file' >>> redirect_to :action => :download >>> >>> end >>> >>> >>> _______________________________________________ >>> Backgroundrb-devel mailing list >>> Backgroundrb-devel at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/backgroundrb-devel >>> >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From guillaume.nourry.marquis at gmail.com Thu Oct 29 12:26:40 2009 From: guillaume.nourry.marquis at gmail.com (Guillaume Nourry-Marquis) Date: Thu, 29 Oct 2009 12:26:40 -0400 Subject: [Backgroundrb-devel] Persistent jobs - when scheduled Message-ID: <1256833600.15309.45.camel@gnourry-marquis-desktop> Hi, I'm trying to do the following : 1- Run a Worker and a method within it every 15 minutes 2- Have a log of the job last runtime, in the database table bdrd_job_queue. What I've done : I have a schedule every 15 min in my backgroundRB.yml file The method call has a persistent_job.finish! call, but it's not working, because the persistent_job object is nil. How can I ensure it's logged in the DB, but still automatically scheduled from backgroundRB.yml? Thanks GuillaumeNM