[Backgroundrb-devel] Cannot connect when spawning new workers on demand

Ger Apeldoorn gapeldoorn at wehkamp.nl
Tue Jan 22 03:29:42 EST 2008


Hi!

I'm using the latest&greatest backgroundrb with rails 2.0.2 on ubuntu
dapper.

I've made an app that lets you run a query on several servers at once,
which are selected at runtime. Therefore, for each server that is
selected, I spawn a new worker and assign its work.
After everything is completed, the workers are deleted.

I often get this error:
BackgrounDRb::BdrbConnError in Multi com/indexController#uitvoeren 
Not able to connect

Here's the code that spawns the workers: (sorry for the linewraps)

  def uitvoeren
    # put selected servers in a session
    session[:selectedservers] = params[:servers]
    session[:running_cmd] = 1
    @selected_servers = System.find_all_by_id(params[:servers])
    @selected_servers.each do |svr|
      # spawn new process
      MiddleMan.new_worker(:worker => :remote_command_worker, :job_key
=> svr.name)
      MiddleMan.ask_work(:worker => :remote_command_worker, :job_key =>
svr.name, :worker_method => :do_work, :data => {:svr =>
svr.name, :command =>
MultiComCommand.find_by_id(params[:commando]).command})
    end
  end

When I select only a few servers, it works just fine! There is no
definable threshold, I've had failures with only 4 servers selected and
success with 12 servers selected.

After such a connection error, the worker processes are still running:
$ ps -ef | grep worker
09:08 ?        00:00:00 ruby log_worker               
09:08 ?        00:00:00 ruby remote_command_worker    
09:08 ?        00:00:00 ruby remote_command_worker    
09:08 ?        00:00:00 ruby remote_command_worker    
09:08 ?        00:00:00 ruby remote_command_worker    
09:08 ?        00:00:00 ruby remote_command_worker 

Your help is VERY MUCH appreciated!

Thanks,
Ger.




More information about the Backgroundrb-devel mailing list