[Backgroundrb-devel] [ANN] New release! and Database access for workers
P.Mark Anderson
mark at martianrover.com
Wed Jun 14 20:15:30 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
More information about the Backgroundrb-devel
mailing list