[Backgroundrb-devel] Problems running backgroundrb
hemant
gethemant at gmail.com
Mon Feb 11 13:28:35 EST 2008
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.
--
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
More information about the Backgroundrb-devel
mailing list