[Backgroundrb-devel] [ANN] New release! and Database access for workers

Ezra Zygmuntowicz ezmobius at gmail.com
Wed Jun 14 22:21:45 EDT 2006


>> 	BackgrounDRb doesn't need all of rails loaded. THat would make it
>> consume way more memory then it needs
> Hi Ezra - I got it to work for me.  At first I changed the start
> script and config to include only the libs I needed, but then I
> needed a plugin (acts_as_taggable), so I included that too, but then
> the 'logger' instance used by my models wasn't defined, so I decided
> to simply include the whole Rails environment and now all is well.
> Is it the most efficient use of memory?  No.  But oh well.  I need it.
> To include the whole Rails environment I made this change in script/
> backgroundrb/start:
> if CONFIG['load_rails']
>    require "#{RAILS_ROOT}/config/environment"
> end
> Alternatively, you can pick and choose environment config libs and
> plugins by adding this to your config/backgroundrb.yml:
> libs:
>      environments:
>          pocket_config
> 	some_other_config
>      plugins:
>          acts_as_taggable
> 	some_other_plugin
> And then change script/backgroundrb/start:
> # Require all worker classes in lib/workers/
> Dir["#{RAILS_ROOT}/lib/workers/*"].each{ |worker| require worker }
> # Load other libraries
> unless CONFIG['libs'].nil?
>     env_libs = CONFIG['libs']['environments']
>     plugin_libs = CONFIG['libs']['plugins']
>     env_libs.each {|lib| require "#{RAILS_ROOT}/config/environments/#
> {lib}"} unless env_libs.nil?
>     plugin_libs.each {|plugin| require "#{RAILS_ROOT}/vendor/plugins/#
> {plugin}/init"} unless plugin_libs.nil?
> end
> HTH.
> I might name my firstborn Ezra now.
> pmark

	Cool man I'm glad its working good for you. And thanks for the  
additions. Now that we have a real config file stuff like this is  
easy to add. I'll check this in when I get a chance.

	Can you do me a favor? Start up your drb server that requires all  
your rails stuff and use top to see how much mem it takes up. If you  
can just copy paste some top output that would be cool. I'm curious  
to see how much ram it takes up with everything loaded. When I run it  
without ActiveRecord or anything other then itself and a few workers  
it only takes up 2-3Mb of ram. ActiveRecord adds a bit to this  
bringing it up to 8Mb or so.


More information about the Backgroundrb-devel mailing list