[Backgroundrb-devel] :load_rails

Charles Brian Quinn me at seebq.com
Mon Aug 7 12:01:52 EDT 2006


The only side-effect is that now your backgroundrb process takes up
about the same amount of memory as a rails instance -- could be 25-30
MB depending on what all you got in there.

I personally do this too - editing the start script to load rails this
way, as well:

# load EVERYTHING
if CONFIG['load_rails']
   require "#{RAILS_ROOT}/config/environment"
end

Here's how I'd do it --

load_rails = true    loads rails

load_active_record = true loads just activerecord

the default is to load all of rails now .... though.

patch here:

Index: script/backgroundrb/start
===================================================================
--- script/backgroundrb/start   (revision 37)
+++ script/backgroundrb/start   (working copy)
@@ -62,10 +62,14 @@
 rescue
   CONFIG = defaults
 end
-if CONFIG['load_rails']
+if CONFIG['load_active_record']
   ActiveRecord::Base.allow_concurrency = true
   ActiveRecord::Base.establish_connection(YAML.load(ERB.new(IO.read("#{RAILS_ROOT}/#{CONFIG['database_yml']}")).result)[CONFIG['environment']])
 end
+if CONFIG['load_rails']
+  require "#{RAILS_ROOT}/config/environment"
+end
+
 # Require all worker classes in lib/workers/
 Dir["#{RAILS_ROOT}/lib/workers/*.rb"].each{ |worker| require worker }


this might save some headache on the list, and for those who care
about memory, they can drop it down to just load AR and the models
they need.

cheers....

On 8/7/06, Michael Siebert <info at siebert-wd.de> wrote:
> if CONFIG['load_rails']
>   ActiveRecord::Base.allow_concurrency = true
>
> ActiveRecord::Base.establish_connection(YAML.load(ERB.new(IO.read("#{RAILS_ROOT}/#{CONFIG['database_yml']}")).result)[CONFIG['environment']])
> end
>
> if i read the code right, this option doesnt really load rails. wouldnt it
> be better (for those who rely on the config vars set in environment.rb) to
>   require(File.join(RAILS_ROOT, 'config', 'environment'))
> so the rails core is started up and even the ActionMailer setup is loaded
> DRY. and the better, sql logs go to (devel|test|production).log
>
> what does everone think about it? are there any side-effects i dont know
> about?
>
> --
> Michael Siebert <info at siebert-wd.de>
>
> www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium
> _______________________________________________
> Backgroundrb-devel mailing list
> Backgroundrb-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/backgroundrb-devel
>
>


-- 
Charles Brian Quinn
self-promotion: www.seebq.com
highgroove studios: www.highgroove.com
slingshot hosting: www.slingshothosting.com


More information about the Backgroundrb-devel mailing list