[Backgroundrb-devel] Getting started

Richard Everhart rich.everhart at gmail.com
Wed Feb 13 01:47:42 EST 2008


On Feb 12, 2008 6:02 PM, hemant <gethemant at gmail.com> wrote:
>
> On Wed, Feb 13, 2008 at 7:19 AM, Richard Everhart
> <rich.everhart at gmail.com> wrote:
> >
> > I upgraded ruby right before I wrote my original message and that was
> >  causing some problems.  That's fixed but I still get the 'Not able to
> >  connect' error.  In backgroundrb_server.log there seem to really be
> >  two errors:
> >
> >  /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
> >  `gem_original_require': no such file to load --  (LoadError)
> >        from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
> >  `require'
> >        from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:495:in
> >  `require'
> >        from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:342:in
> >  `new_constants_in'
> >        from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:495:in
> >  `require'
> >        from /home/reverhart/drb_test/vendor/plugins/backgroundrb/framework/packet_master.rb:113:in
> >  `start_worker'
> >  [...snip...]
> >  /home/reverhart/drb_test/vendor/plugins/backgroundrb/lib/../framework/nbio.rb:24:in
> >  `read_data': Packet::DisconnectError (Packet::DisconnectError)
> >        from /home/reverhart/drb_test/vendor/plugins/backgroundrb/framework/worker.rb:47:in
> >  `handle_internal_messages'
> >        from /home/reverhart/drb_test/vendor/plugins/backgroundrb/framework/core.rb:154:in
> >  `start_reactor'
> >  [...snip...]
> >
> >  The first error seems to be due to a ruby and/or rails configuration
> >  error.  However, I've seen this error before, and the '--' in the
> >  error message is usually followed by the name of the file that can't
> >  be loaded.
> >
>
> Did you define a worker before starting backgroundrb server? Above
> error is because, bdrb is not able to load defined worker.
> If you have the worker defined can we see the code of the worker.
>

Here is my controller and worker:

class TestdrbController < ApplicationController
  def do_fib
    puts ">>> do_fib: #{params[:input]}"

    session[:job_key] = MiddleMan.new_worker(:class =>
:fibonacci_worker, :data => params[:input])

    puts "Job key: #{session[:job_key]}"

    MiddleMan.send_request(:worker => :fibonacci_worker,
:worker_method => :do_work, :data => params[:input])

    puts "<<< do_fib"

    render :action => 'result'
  end

  def result
    puts ">>> result"
    MiddleMan.delete_worker(:worker => :fibonacci_worker, :job_key =>
session[:job_key])
    puts "<<< result"
  end
end

class FibonacciWorker < BackgrounDRb::MetaWorker
  include Fibonacci

  set_worker_name :fibonacci_worker
  set_no_auto_load true

  def create(args = nil)
    logger.info("Worker create: '#{args}'")

    register_status("Processing started")

    n = args.to_i
    logger.info("Worker result: #{f(n)}")
  end

  def do_work(data)
    logger.info ">>> do_work"

    result = f(data.to_i)
    logger.info "Worker result: #{result}"

    return result
  end
end


Thanks again.

Richard


More information about the Backgroundrb-devel mailing list