[Backgroundrb-devel] failed to find slave socket - (RuntimeError)

Ezra Zygmuntowicz ezmobius at gmail.com
Thu Feb 22 13:57:49 EST 2007


Hi-

	You are trying to spawn new workers too fast for the new  
architecture in bdrb. With a job like this that you want to run every  
5 seconds you are way better of creating a single worker that lives  
forever and just does a loop and sleep then does the work you want.

	Trying to spawn new workers every 5 seconds will work with the old  
version of the plugin but not with the new version.  Try something  
more like this:

class ResearchesWorker < BackgrounDRb::Worker::RailsBase
	def do_work(args)
             loop {
		completed = RunningResearch.find(:all,:conditions => ["endtime  
< ?",Time.now])
		for complete in completed
			complete.complete
		end
               sleep 5
	     }
	end
end
ResearchesWorker.register


	Then just have this worker get started at server boot time or  
whatever and run forever.

-Ezra


On Feb 22, 2007, at 6:29 AM, Alessio Bernesco Làvore wrote:

> Hi everyone,
>
> I've a class that try to spawn two workers, every 5 seconds.
>
> The code is something like:
>
> while true do
> 	MiddleMan.new_worker(:class => :researches_worker,:job_key
> => :researches)
> 	MiddleMan.new_worker(:class => :products_worker,:job_key  
> => :products)
> 	sleep(5)
> end
>
> I'm using ":job_key", so if a worker hasn't already ended its work
> after five seconds, it's not duplicated.
>
> The code inside the worker is something like:
>
> class ResearchesWorker < BackgrounDRb::Worker::RailsBase
> 	def do_work(args)
> 		completed = RunningResearch.find(:all,:conditions => ["endtime
> < ?",Time.now])
> 		for complete in completed
> 			complete.complete
> 		end
> 		self.delete
> 	end
> end
> ResearchesWorker.register
>
> After 4 or 5 minutes of working, the worker stops to respond and i've
> this error in the log file:
>
> 20070222-15:13:37 (15574) failed to find slave socket - (RuntimeError)
> 20070222-15:13:37 (15574) /usr/local/lib/ruby/gems/1.8/gems/
> slave-1.2.0/lib/slave.rb:435:in `initialize'
> 20070222-15:13:37 (15574) /Users/abernesco/Documents/ruby/alfaomega/
> vendor/plugins/backgroundrb/server/lib/backgroundrb/middleman.rb:
> 210:in `new'
> 20070222-15:13:37 (15574) /Users/abernesco/Documents/ruby/alfaomega/
> vendor/plugins/backgroundrb/server/lib/backgroundrb/middleman.rb:
> 210:in `new_worker'
> 20070222-15:13:37 (15574) /Users/abernesco/Documents/ruby/alfaomega/
> vendor/plugins/backgroundrb/server/lib/backgroundrb/thread_pool.rb:
> 36:in `dispatch'
> 20070222-15:13:37 (15574) /Users/abernesco/Documents/ruby/alfaomega/
> vendor/plugins/backgroundrb/server/lib/backgroundrb/thread_pool.rb:
> 22:in `initialize'
> 20070222-15:13:37 (15574) /Users/abernesco/Documents/ruby/alfaomega/
> vendor/plugins/backgroundrb/server/lib/backgroundrb/thread_pool.rb:
> 22:in `new'
> 20070222-15:13:37 (15574) /Users/abernesco/Documents/ruby/alfaomega/
> vendor/plugins/backgroundrb/server/lib/backgroundrb/thread_pool.rb:
> 22:in `dispatch'
> 20070222-15:13:37 (15574) /Users/abernesco/Documents/ruby/alfaomega/
> vendor/plugins/backgroundrb/server/lib/backgroundrb/middleman.rb:
> 199:in `new_worker'
>
>
> I've try to keep the workers class as simple and light as i can...
> any advice about?
>
> Thanks,
> ale.
> _______________________________________________
> Backgroundrb-devel mailing list
> Backgroundrb-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/backgroundrb-devel
>

-- Ezra Zygmuntowicz 
-- Lead Rails Evangelist
-- ez at engineyard.com
-- Engine Yard, Serious Rails Hosting
-- (866) 518-YARD (9273)




More information about the Backgroundrb-devel mailing list