Hi guys, New to backgroundrb, and I like it very much conceptually, but I''m struggling to get it to run successfully. I started with trunk, but was getting a very strange gem require error when starting a worker (though it wasn''t telling me which gem was missing)....see here: http://pastie.caboo.se/150225 So I rolled back to the release 1.0.1 tag but had different problems there. I have my own "acts_as" plugin that''s required in my environment.rb....it''s stored in lib/formatters.rb. However, backgroundrb complains about it not being there in startup: $ script/backgroundrb start /home/jb/workspace/ruby/eqnow_dev/vendor/rails/activerecord/lib/active_record/base.rb:1238:in `method_missing'': undefined method `acts_as_phone_formatter'' for Event:Class (NoMethodError) from /home/jb/workspace/ruby/eqnow_dev/app/models/event.rb:45 from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'' from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'' from /home/jb/workspace/ruby/eqnow_dev/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:495:in `require'' from /home/jb/workspace/ruby/eqnow_dev/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:342:in `new_constants_in'' It''s definitely there in my config/environment.rb: require ''formatters'' My backgroundrb.yml looks like: --- :backgroundrb: :ip: localhost :port: 11006 :environment: development I''m completely at a loss on how to proceed. I''d really like to use it... (I *need* it) but not sure how to get it running properly. Can anyone help? Thanks for any assistance you might provide! John
does require ''lib/formatters'' work? On Feb 10, 2008, at 10:11 PM, John Wells wrote:> Hi guys, > > New to backgroundrb, and I like it very much conceptually, but I''m > struggling to get it to run successfully. I started with trunk, but > was getting a very strange gem require error when starting a worker > (though it wasn''t telling me which gem was missing)....see here: > http://pastie.caboo.se/150225 > > So I rolled back to the release 1.0.1 tag but had different problems > there. I have my own "acts_as" plugin that''s required in my > environment.rb....it''s stored in lib/formatters.rb. However, > backgroundrb complains about it not being there in startup: > > $ script/backgroundrb start > > /home/jb/workspace/ruby/eqnow_dev/vendor/rails/activerecord/lib/ > active_record/base.rb:1238:in > `method_missing'': undefined method `acts_as_phone_formatter'' for > Event:Class (NoMethodError) > from /home/jb/workspace/ruby/eqnow_dev/app/models/event.rb:45 > from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb: > 27:in > `gem_original_require'' > from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb: > 27:in > `require'' > from /home/jb/workspace/ruby/eqnow_dev/vendor/rails/ > activerecord/lib/../../activesupport/lib/active_support/ > dependencies.rb:495:in > `require'' > from /home/jb/workspace/ruby/eqnow_dev/vendor/rails/ > activerecord/lib/../../activesupport/lib/active_support/ > dependencies.rb:342:in > `new_constants_in'' > > It''s definitely there in my config/environment.rb: > > require ''formatters'' > > My backgroundrb.yml looks like: > > --- > :backgroundrb: > :ip: localhost > :port: 11006 > :environment: development > > I''m completely at a loss on how to proceed. I''d really like to use > it... (I *need* it) but not sure how to get it running properly. > > Can anyone help? > > Thanks for any assistance you might provide! > > John > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel
On Mon, 2008-02-11 at 00:55 -0800, Alex Soto wrote:> does require ''lib/formatters'' work? > > > On Feb 10, 2008, at 10:11 PM, John Wells wrote: > > > Hi guys, > > > > New to backgroundrb, and I like it very much conceptually, but I''m > > struggling to get it to run successfully. I started with trunk, but > > was getting a very strange gem require error when starting a worker > > (though it wasn''t telling me which gem was missing)....see here: > > http://pastie.caboo.se/150225Its not complaining about any missing gems, rather its not able to load workers defined inside lib/workers directory. You must define at least one worker, before you can start bdrb. In case, you have already defined a worker, Can we have a look at the code of your worker?> > > > So I rolled back to the release 1.0.1 tag but had different problems > > there. I have my own "acts_as" plugin that''s required in my > > environment.rb....it''s stored in lib/formatters.rb. However, > > backgroundrb complains about it not being there in startup: > > > > $ script/backgroundrb start > > > > /home/jb/workspace/ruby/eqnow_dev/vendor/rails/activerecord/lib/ > > active_record/base.rb:1238:in > > `method_missing'': undefined method `acts_as_phone_formatter'' for > > Event:Class (NoMethodError) > > from /home/jb/workspace/ruby/eqnow_dev/app/models/event.rb:45 > > from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb: > > 27:in > > `gem_original_require'' > > from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb: > > 27:in > > `require'' > > from /home/jb/workspace/ruby/eqnow_dev/vendor/rails/ > > activerecord/lib/../../activesupport/lib/active_support/ > > dependencies.rb:495:in > > `require'' > > from /home/jb/workspace/ruby/eqnow_dev/vendor/rails/ > > activerecord/lib/../../activesupport/lib/active_support/ > > dependencies.rb:342:in > > `new_constants_in''Well, looks like you have a model Event defined in your app. 1.0.1 release tag has a bug where require statements in bdrb aren''t relative and since bdrb comes with its own Event class, its conflicting. This has been fixed in trunk version of plugin and all the requires are relative, hence, revert back to trunk and create few workers and see if it works. Also, try creating a new rails project and try using bdrb there, it will give you some further information.> > > > It''s definitely there in my config/environment.rb: > > > > require ''formatters'' > > > > My backgroundrb.yml looks like: > > > > --- > > :backgroundrb: > > :ip: localhost > > :port: 11006 > > :environment: developmentThat environment string is redundant since, by default bdrb will load development environment anyways.> > > > I''m completely at a loss on how to proceed. I''d really like to use > > it... (I *need* it) but not sure how to get it running properly. > > > > Can anyone help? > > > > Thanks for any assistance you might provide! > >
On Feb 11, 2008 5:03 AM, hemant kumar <gethemant at gmail.com> wrote:> > On Mon, 2008-02-11 at 00:55 -0800, Alex Soto wrote: > > does require ''lib/formatters'' work? > > > > > > On Feb 10, 2008, at 10:11 PM, John Wells wrote: > > > > > Hi guys, > > > > > > New to backgroundrb, and I like it very much conceptually, but I''m > > > struggling to get it to run successfully. I started with trunk, but > > > was getting a very strange gem require error when starting a worker > > > (though it wasn''t telling me which gem was missing)....see here: > > > http://pastie.caboo.se/150225 > > Its not complaining about any missing gems, rather its not able to load > workers defined inside lib/workers directory. You must define at least > one worker, before you can start bdrb. In case, you have already defined > a worker, Can we have a look at the code of your worker?Thanks for your help. Sure thing...the code is below. However, I''m very curious...how did you determine this was the problem? Just so I know what to look for in the future. ===== controller that instantiates worker ====class Admin::BatchController < Admin::ApplicationController def initialize super @formats = GW::BatchListing::ListingRow.formats @part_of = :admin end def get_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 done errors = "DONE " + MiddleMan.get_worker(session[:job_key]).errors if errors.size > 0 flash[:notice] = errors.join("<br/>") else flash[:notice] = "Successful load." end MiddleMan.delete_worker(session[:job_key]) end def add @user = User.find(params[:id]) @cats = Category.find(:all, :conditions=>"parent_id is null") if request.post? listings = params[:listings] content_type = listings.content_type.chomp if "application/zip"!=content_type and "application/x-zip-compressed"!=content_type flash[:notice] "Only files of type application/zip " + "and application/x-zip-compressed " + "can be used. You uploaded #{content_type}." else # write out to tmp file tmpfile = "/tmp/#{rand 500000}.zip" open(tmpfile, "w") do |f| f << listings.read end parser GW::BatchListing::ListingParser.new(params[:format], params[:listing_type], @user) session[:job_key] MiddleMan.new_worker(:class => :foo_worker, :args => parser) end end end end ===== and the worker itself ====class BatchImportWorker < BackgrounDRb::MetaWorker attr_reader :progress attr_reader :errors set_worker_name :batch_import_worker def create(args = nil) # this method is called, when worker is loaded for the first time end def do_work(parser) @progress = 0 @errors = parser.process(tmpfile) end end
On Mon, Feb 11, 2008 at 8:20 PM, John Wells <lists at sourceillustrated.com> wrote:> On Feb 11, 2008 5:03 AM, hemant kumar <gethemant at gmail.com> wrote: > > > > On Mon, 2008-02-11 at 00:55 -0800, Alex Soto wrote: > > > does require ''lib/formatters'' work? > > > > > > > > > On Feb 10, 2008, at 10:11 PM, John Wells wrote: > > > > > > > Hi guys, > > > > > > > > New to backgroundrb, and I like it very much conceptually, but I''m > > > > struggling to get it to run successfully. I started with trunk, but > > > > was getting a very strange gem require error when starting a worker > > > > (though it wasn''t telling me which gem was missing)....see here: > > > > http://pastie.caboo.se/150225 > > > > Its not complaining about any missing gems, rather its not able to load > > workers defined inside lib/workers directory. You must define at least > > one worker, before you can start bdrb. In case, you have already defined > > a worker, Can we have a look at the code of your worker? > > Thanks for your help. Sure thing...the code is below. However, I''m > very curious...how did you determine this was the problem? Just so I > know what to look for in the future.Because, when I saw error at: http://pastie.caboo.se/150225 It clearly says thats start_worker is failing on 114 line. Generally this happens, when bdrb is not able to load a particular worker file. Also, you see empty string "gem_original_require'': no such file to load -- (LoadError)" because bdrb is not able to get name of worker file to load correctly.> > ===== controller that instantiates worker ====> class Admin::BatchController < Admin::ApplicationController > > def initialize > super > @formats = GW::BatchListing::ListingRow.formats > @part_of = :admin > end > > def get_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 done > errors = "DONE " + MiddleMan.get_worker(session[:job_key]).errors > if errors.size > 0 > flash[:notice] = errors.join("<br/>") > else > flash[:notice] = "Successful load." > end > MiddleMan.delete_worker(session[:job_key]) > end > > def add > @user = User.find(params[:id]) > @cats = Category.find(:all, :conditions=>"parent_id is null") > if request.post? > listings = params[:listings] > content_type = listings.content_type.chomp > if "application/zip"!=content_type and > "application/x-zip-compressed"!=content_type > flash[:notice] > "Only files of type application/zip " + > "and application/x-zip-compressed " + > "can be used. You uploaded #{content_type}." > else > # write out to tmp file > tmpfile = "/tmp/#{rand 500000}.zip" > open(tmpfile, "w") do |f| > f << listings.read > end > parser > GW::BatchListing::ListingParser.new(params[:format], > params[:listing_type], > @user) > session[:job_key] > MiddleMan.new_worker(:class => :foo_worker, > :args => parser) > end > end > end > end >There are couple of problems with above code, for example, MiddleMan.get_worker is not defined. To get an idea about, which methods are defined for MiddleMan, have a look at, http://backgroundrb.rubyforge.org/classes/BackgrounDRb/WorkerProxy.html Also, you should read README file that comes with plugin.> ===== and the worker itself ====> class BatchImportWorker < BackgrounDRb::MetaWorker > attr_reader :progress > attr_reader :errors > set_worker_name :batch_import_worker > > def create(args = nil) > # this method is called, when worker is loaded for the first time > end > > def do_work(parser) > @progress = 0 > @errors = parser.process(tmpfile) > end > endWell, I find no problems with above worker code, and it should load. Create a fresh rails app and see if bdrb works there. -- Let them talk of their oriental summer climes of everlasting conservatories; give me the privilege of making my own summer with my own coals. http://gnufied.org
On Feb 11, 2008 1:28 PM, hemant <gethemant at gmail.com> wrote:> On Mon, Feb 11, 2008 at 8:20 PM, John Wells <lists at sourceillustrated.com> wrote: > > On Feb 11, 2008 5:03 AM, hemant kumar <gethemant at gmail.com> wrote: > > > > > > On Mon, 2008-02-11 at 00:55 -0800, Alex Soto wrote: > > > > does require ''lib/formatters'' work? > > > > > > > > > > > > On Feb 10, 2008, at 10:11 PM, John Wells wrote: > > > > > > > > > Hi guys, > > > > > > > > > > New to backgroundrb, and I like it very much conceptually, but I''m > > > > > struggling to get it to run successfully. I started with trunk, but > > > > > was getting a very strange gem require error when starting a worker > > > > > (though it wasn''t telling me which gem was missing)....see here: > > > > > http://pastie.caboo.se/150225 > > > > > > Its not complaining about any missing gems, rather its not able to load > > > workers defined inside lib/workers directory. You must define at least > > > one worker, before you can start bdrb. In case, you have already defined > > > a worker, Can we have a look at the code of your worker? > > > > Thanks for your help. Sure thing...the code is below. However, I''m > > very curious...how did you determine this was the problem? Just so I > > know what to look for in the future. > > Because, when I saw error at: > > http://pastie.caboo.se/150225 > > It clearly says thats start_worker is failing on 114 line. Generally > this happens, when bdrb is not able to load a particular worker file. > Also, you see empty string "gem_original_require'': no such file to > load -- (LoadError)" because bdrb is not able to get name of worker > file to load correctly. > > > > > > > ===== controller that instantiates worker ====> > class Admin::BatchController < Admin::ApplicationController > > > > def initialize > > super > > @formats = GW::BatchListing::ListingRow.formats > > @part_of = :admin > > end > > > > def get_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 done > > errors = "DONE " + MiddleMan.get_worker(session[:job_key]).errors > > if errors.size > 0 > > flash[:notice] = errors.join("<br/>") > > else > > flash[:notice] = "Successful load." > > end > > MiddleMan.delete_worker(session[:job_key]) > > end > > > > def add > > @user = User.find(params[:id]) > > @cats = Category.find(:all, :conditions=>"parent_id is null") > > if request.post? > > listings = params[:listings] > > content_type = listings.content_type.chomp > > if "application/zip"!=content_type and > > "application/x-zip-compressed"!=content_type > > flash[:notice] > > "Only files of type application/zip " + > > "and application/x-zip-compressed " + > > "can be used. You uploaded #{content_type}." > > else > > # write out to tmp file > > tmpfile = "/tmp/#{rand 500000}.zip" > > open(tmpfile, "w") do |f| > > f << listings.read > > end > > parser > > GW::BatchListing::ListingParser.new(params[:format], > > params[:listing_type], > > @user) > > session[:job_key] > > MiddleMan.new_worker(:class => :foo_worker, > > :args => parser) > > end > > end > > end > > end > > > > There are couple of problems with above code, for example, > MiddleMan.get_worker is not defined. To get an idea about, which > methods are defined for MiddleMan, have a look at, > > http://backgroundrb.rubyforge.org/classes/BackgrounDRb/WorkerProxy.html > > Also, you should read README file that comes with plugin. > > > ===== and the worker itself ====> > class BatchImportWorker < BackgrounDRb::MetaWorker > > attr_reader :progress > > attr_reader :errors > > set_worker_name :batch_import_worker > > > > def create(args = nil) > > # this method is called, when worker is loaded for the first time > > end > > > > def do_work(parser) > > @progress = 0 > > @errors = parser.process(tmpfile) > > end > > end > > Well, I find no problems with above worker code, and it should load. > Create a fresh rails app and see if bdrb works there.Ok, sorry... I was working from the old InfoQ article by Ezra and the api docs. I probably made some bad assumptions there...I will take a hard look and try it again. Thanks for your help! John
On Tue, Feb 12, 2008 at 12:05 AM, John Wells <lists at sourceillustrated.com> wrote:> > On Feb 11, 2008 1:28 PM, hemant <gethemant at gmail.com> wrote: > > On Mon, Feb 11, 2008 at 8:20 PM, John Wells <lists at sourceillustrated.com> wrote: > > > On Feb 11, 2008 5:03 AM, hemant kumar <gethemant at gmail.com> wrote: > > > > > > > > On Mon, 2008-02-11 at 00:55 -0800, Alex Soto wrote: > > > > > does require ''lib/formatters'' work? > > > > > > > > > > > > > > > On Feb 10, 2008, at 10:11 PM, John Wells wrote: > > > > > > > > > > > Hi guys, > > > > > > > > > > > > New to backgroundrb, and I like it very much conceptually, but I''m > > > > > > struggling to get it to run successfully. I started with trunk, but > > > > > > was getting a very strange gem require error when starting a worker > > > > > > (though it wasn''t telling me which gem was missing)....see here: > > > > > > http://pastie.caboo.se/150225 > > > > > > > > Its not complaining about any missing gems, rather its not able to load > > > > workers defined inside lib/workers directory. You must define at least > > > > one worker, before you can start bdrb. In case, you have already defined > > > > a worker, Can we have a look at the code of your worker? > > > > > > Thanks for your help. Sure thing...the code is below. However, I''m > > > very curious...how did you determine this was the problem? Just so I > > > know what to look for in the future. > > > > Because, when I saw error at: > > > > http://pastie.caboo.se/150225 > > > > It clearly says thats start_worker is failing on 114 line. Generally > > this happens, when bdrb is not able to load a particular worker file. > > Also, you see empty string "gem_original_require'': no such file to > > load -- (LoadError)" because bdrb is not able to get name of worker > > file to load correctly. > > > > > > > > > > > > ===== controller that instantiates worker ====> > > class Admin::BatchController < Admin::ApplicationController > > > > > > def initialize > > > super > > > @formats = GW::BatchListing::ListingRow.formats > > > @part_of = :admin > > > end > > > > > > def get_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 done > > > errors = "DONE " + MiddleMan.get_worker(session[:job_key]).errors > > > if errors.size > 0 > > > flash[:notice] = errors.join("<br/>") > > > else > > > flash[:notice] = "Successful load." > > > end > > > MiddleMan.delete_worker(session[:job_key]) > > > end > > > > > > def add > > > @user = User.find(params[:id]) > > > @cats = Category.find(:all, :conditions=>"parent_id is null") > > > if request.post? > > > listings = params[:listings] > > > content_type = listings.content_type.chomp > > > if "application/zip"!=content_type and > > > "application/x-zip-compressed"!=content_type > > > flash[:notice] > > > "Only files of type application/zip " + > > > "and application/x-zip-compressed " + > > > "can be used. You uploaded #{content_type}." > > > else > > > # write out to tmp file > > > tmpfile = "/tmp/#{rand 500000}.zip" > > > open(tmpfile, "w") do |f| > > > f << listings.read > > > end > > > parser > > > GW::BatchListing::ListingParser.new(params[:format], > > > params[:listing_type], > > > @user) > > > session[:job_key] > > > MiddleMan.new_worker(:class => :foo_worker, > > > :args => parser) > > > end > > > end > > > end > > > end > > > > > > > There are couple of problems with above code, for example, > > MiddleMan.get_worker is not defined. To get an idea about, which > > methods are defined for MiddleMan, have a look at, > > > > http://backgroundrb.rubyforge.org/classes/BackgrounDRb/WorkerProxy.html > > > > Also, you should read README file that comes with plugin. > > > > > ===== and the worker itself ====> > > class BatchImportWorker < BackgrounDRb::MetaWorker > > > attr_reader :progress > > > attr_reader :errors > > > set_worker_name :batch_import_worker > > > > > > def create(args = nil) > > > # this method is called, when worker is loaded for the first time > > > end > > > > > > def do_work(parser) > > > @progress = 0 > > > @errors = parser.process(tmpfile) > > > end > > > end > > > > Well, I find no problems with above worker code, and it should load. > > Create a fresh rails app and see if bdrb works there. > > > Ok, sorry... I was working from the old InfoQ article by Ezra and the > api docs. I probably made some bad assumptions there...I will take a > hard look and try it again. > > Thanks for your help!Just catching up on this. So, did you manage to get it work after reading latest docs? If yes, can you tell us, why bdrb was not able to load your worker?
On Feb 12, 2008 9:03 PM, hemant <gethemant at gmail.com> wrote:> On Tue, Feb 12, 2008 at 12:05 AM, John Wells > > <lists at sourceillustrated.com> wrote: > > > > On Feb 11, 2008 1:28 PM, hemant <gethemant at gmail.com> wrote: > > > On Mon, Feb 11, 2008 at 8:20 PM, John Wells <lists at sourceillustrated.com> wrote: > > > > On Feb 11, 2008 5:03 AM, hemant kumar <gethemant at gmail.com> wrote: > > > > > > > > > > On Mon, 2008-02-11 at 00:55 -0800, Alex Soto wrote: > > > > > > does require ''lib/formatters'' work? > > > > > > > > > > > > > > > > > > On Feb 10, 2008, at 10:11 PM, John Wells wrote: > > > > > > > > > > > > > Hi guys, > > > > > > > > > > > > > > New to backgroundrb, and I like it very much conceptually, but I''m > > > > > > > struggling to get it to run successfully. I started with trunk, but > > > > > > > was getting a very strange gem require error when starting a worker > > > > > > > (though it wasn''t telling me which gem was missing)....see here: > > > > > > > http://pastie.caboo.se/150225 > > > > > > > > > > Its not complaining about any missing gems, rather its not able to load > > > > > workers defined inside lib/workers directory. You must define at least > > > > > one worker, before you can start bdrb. In case, you have already defined > > > > > a worker, Can we have a look at the code of your worker? > > > > > > > > Thanks for your help. Sure thing...the code is below. However, I''m > > > > very curious...how did you determine this was the problem? Just so I > > > > know what to look for in the future. > > > > > > Because, when I saw error at: > > > > > > http://pastie.caboo.se/150225 > > > > > > It clearly says thats start_worker is failing on 114 line. Generally > > > this happens, when bdrb is not able to load a particular worker file. > > > Also, you see empty string "gem_original_require'': no such file to > > > load -- (LoadError)" because bdrb is not able to get name of worker > > > file to load correctly. > > > > > > > > > > > > > > > > > ===== controller that instantiates worker ====> > > > class Admin::BatchController < Admin::ApplicationController > > > > > > > > def initialize > > > > super > > > > @formats = GW::BatchListing::ListingRow.formats > > > > @part_of = :admin > > > > end > > > > > > > > def get_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 done > > > > errors = "DONE " + MiddleMan.get_worker(session[:job_key]).errors > > > > if errors.size > 0 > > > > flash[:notice] = errors.join("<br/>") > > > > else > > > > flash[:notice] = "Successful load." > > > > end > > > > MiddleMan.delete_worker(session[:job_key]) > > > > end > > > > > > > > def add > > > > @user = User.find(params[:id]) > > > > @cats = Category.find(:all, :conditions=>"parent_id is null") > > > > if request.post? > > > > listings = params[:listings] > > > > content_type = listings.content_type.chomp > > > > if "application/zip"!=content_type and > > > > "application/x-zip-compressed"!=content_type > > > > flash[:notice] > > > > "Only files of type application/zip " + > > > > "and application/x-zip-compressed " + > > > > "can be used. You uploaded #{content_type}." > > > > else > > > > # write out to tmp file > > > > tmpfile = "/tmp/#{rand 500000}.zip" > > > > open(tmpfile, "w") do |f| > > > > f << listings.read > > > > end > > > > parser > > > > GW::BatchListing::ListingParser.new(params[:format], > > > > params[:listing_type], > > > > @user) > > > > session[:job_key] > > > > MiddleMan.new_worker(:class => :foo_worker, > > > > :args => parser) > > > > end > > > > end > > > > end > > > > end > > > > > > > > > > There are couple of problems with above code, for example, > > > MiddleMan.get_worker is not defined. To get an idea about, which > > > methods are defined for MiddleMan, have a look at, > > > > > > http://backgroundrb.rubyforge.org/classes/BackgrounDRb/WorkerProxy.html > > > > > > Also, you should read README file that comes with plugin. > > > > > > > ===== and the worker itself ====> > > > class BatchImportWorker < BackgrounDRb::MetaWorker > > > > attr_reader :progress > > > > attr_reader :errors > > > > set_worker_name :batch_import_worker > > > > > > > > def create(args = nil) > > > > # this method is called, when worker is loaded for the first time > > > > end > > > > > > > > def do_work(parser) > > > > @progress = 0 > > > > @errors = parser.process(tmpfile) > > > > end > > > > end > > > > > > Well, I find no problems with above worker code, and it should load. > > > Create a fresh rails app and see if bdrb works there. > > > > > > Ok, sorry... I was working from the old InfoQ article by Ezra and the > > api docs. I probably made some bad assumptions there...I will take a > > hard look and try it again. > > > > Thanks for your help! > > Just catching up on this. So, did you manage to get it work after > reading latest docs? > If yes, can you tell us, why bdrb was not able to load your worker? >It was a number of small little errors, and some big ones. Perhaps the most damning was: @errors = parser.process(tmpfile) You''ll note tmpfile doesn''t exist in this context ;) That would cause a problem. I have my solution working now and it''s working well. I really appreciate your help. My biggest hurdle with backgroundrb was the fact that I have some very complicated business rules taking place on the brdb side of things, and without an easy way to step through these with a debugger, lots of things can go wrong and it makes life more difficult. Running script/backgroundrb without arguments and using puts and inspect helps, but hooking to it with a debugger so that one could inspect variables, etc would be extremely useful. I started going down the path of getting NetBeans'' debugger to work with it, but quickly realized it was going to take more time than I had given my current project. Anyway, thanks very much for your help! John
On Wed, 2008-02-13 at 09:20 -0500, John Wells wrote:> On Feb 12, 2008 9:03 PM, hemant <gethemant at gmail.com> wrote: > > On Tue, Feb 12, 2008 at 12:05 AM, John Wells > > > > <lists at sourceillustrated.com> wrote: > > > > > > On Feb 11, 2008 1:28 PM, hemant <gethemant at gmail.com> wrote: > > > > On Mon, Feb 11, 2008 at 8:20 PM, John Wells <lists at sourceillustrated.com> wrote: > > > > > On Feb 11, 2008 5:03 AM, hemant kumar <gethemant at gmail.com> wrote: > > > > > > > > > > > > On Mon, 2008-02-11 at 00:55 -0800, Alex Soto wrote: > > > > > > > does require ''lib/formatters'' work? > > > > > > > > > > > > > > > > > > > > > On Feb 10, 2008, at 10:11 PM, John Wells wrote: > > > > > > > > > > > > > > > Hi guys, > > > > > > > > > > > > > > > > New to backgroundrb, and I like it very much conceptually, but I''m > > > > > > > > struggling to get it to run successfully. I started with trunk, but > > > > > > > > was getting a very strange gem require error when starting a worker > > > > > > > > (though it wasn''t telling me which gem was missing)....see here: > > > > > > > > http://pastie.caboo.se/150225 > > > > > > > > > > > > Its not complaining about any missing gems, rather its not able to load > > > > > > workers defined inside lib/workers directory. You must define at least > > > > > > one worker, before you can start bdrb. In case, you have already defined > > > > > > a worker, Can we have a look at the code of your worker? > > > > > > > > > > Thanks for your help. Sure thing...the code is below. However, I''m > > > > > very curious...how did you determine this was the problem? Just so I > > > > > know what to look for in the future. > > > > > > > > Because, when I saw error at: > > > > > > > > http://pastie.caboo.se/150225 > > > > > > > > It clearly says thats start_worker is failing on 114 line. Generally > > > > this happens, when bdrb is not able to load a particular worker file. > > > > Also, you see empty string "gem_original_require'': no such file to > > > > load -- (LoadError)" because bdrb is not able to get name of worker > > > > file to load correctly. > > > > > > > > > > > > > > > > > > > > > > ===== controller that instantiates worker ====> > > > > class Admin::BatchController < Admin::ApplicationController > > > > > > > > > > def initialize > > > > > super > > > > > @formats = GW::BatchListing::ListingRow.formats > > > > > @part_of = :admin > > > > > end > > > > > > > > > > def get_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 done > > > > > errors = "DONE " + MiddleMan.get_worker(session[:job_key]).errors > > > > > if errors.size > 0 > > > > > flash[:notice] = errors.join("<br/>") > > > > > else > > > > > flash[:notice] = "Successful load." > > > > > end > > > > > MiddleMan.delete_worker(session[:job_key]) > > > > > end > > > > > > > > > > def add > > > > > @user = User.find(params[:id]) > > > > > @cats = Category.find(:all, :conditions=>"parent_id is null") > > > > > if request.post? > > > > > listings = params[:listings] > > > > > content_type = listings.content_type.chomp > > > > > if "application/zip"!=content_type and > > > > > "application/x-zip-compressed"!=content_type > > > > > flash[:notice] > > > > > "Only files of type application/zip " + > > > > > "and application/x-zip-compressed " + > > > > > "can be used. You uploaded #{content_type}." > > > > > else > > > > > # write out to tmp file > > > > > tmpfile = "/tmp/#{rand 500000}.zip" > > > > > open(tmpfile, "w") do |f| > > > > > f << listings.read > > > > > end > > > > > parser > > > > > GW::BatchListing::ListingParser.new(params[:format], > > > > > params[:listing_type], > > > > > @user) > > > > > session[:job_key] > > > > > MiddleMan.new_worker(:class => :foo_worker, > > > > > :args => parser) > > > > > end > > > > > end > > > > > end > > > > > end > > > > > > > > > > > > > There are couple of problems with above code, for example, > > > > MiddleMan.get_worker is not defined. To get an idea about, which > > > > methods are defined for MiddleMan, have a look at, > > > > > > > > http://backgroundrb.rubyforge.org/classes/BackgrounDRb/WorkerProxy.html > > > > > > > > Also, you should read README file that comes with plugin. > > > > > > > > > ===== and the worker itself ====> > > > > class BatchImportWorker < BackgrounDRb::MetaWorker > > > > > attr_reader :progress > > > > > attr_reader :errors > > > > > set_worker_name :batch_import_worker > > > > > > > > > > def create(args = nil) > > > > > # this method is called, when worker is loaded for the first time > > > > > end > > > > > > > > > > def do_work(parser) > > > > > @progress = 0 > > > > > @errors = parser.process(tmpfile) > > > > > end > > > > > end > > > > > > > > Well, I find no problems with above worker code, and it should load. > > > > Create a fresh rails app and see if bdrb works there. > > > > > > > > > Ok, sorry... I was working from the old InfoQ article by Ezra and the > > > api docs. I probably made some bad assumptions there...I will take a > > > hard look and try it again. > > > > > > Thanks for your help! > > > > Just catching up on this. So, did you manage to get it work after > > reading latest docs? > > If yes, can you tell us, why bdrb was not able to load your worker? > > > > It was a number of small little errors, and some big ones. Perhaps the > most damning was: > > @errors = parser.process(tmpfile) > > You''ll note tmpfile doesn''t exist in this context ;) That would cause a problem. > > I have my solution working now and it''s working well. I really > appreciate your help. > > My biggest hurdle with backgroundrb was the fact that I have some very > complicated business rules taking place on the brdb side of things, > and without an easy way to step through these with a debugger, lots of > things can go wrong and it makes life more difficult. Running > script/backgroundrb without arguments and using puts and inspect > helps, but hooking to it with a debugger so that one could inspect > variables, etc would be extremely useful. I started going down the > path of getting NetBeans'' debugger to work with it, but quickly > realized it was going to take more time than I had given my current > project.I have similar project, where I have complicated set of business rules in workers. Stepping through debugger is no solution, Please write test cases for workers, thats the only way.