From 560216c2fecfc5cf3489f749dc7a0221fd78eb26 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 9 Nov 2009 17:15:58 -0800 Subject: Load Unicorn constants when building app This will benefit users of a copy-on-write-friendly memory manager provided with Ruby Enterprise Edition. Additionally, this will the reduce maintenance impact on Rainbows! in the future since load/require are not thread-safe under 1.9. --- lib/unicorn.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib') diff --git a/lib/unicorn.rb b/lib/unicorn.rb index 7fa8468..a696402 100644 --- a/lib/unicorn.rb +++ b/lib/unicorn.rb @@ -725,6 +725,10 @@ module Unicorn def build_app! if app.respond_to?(:arity) && app.arity == 0 + # exploit COW in case of preload_app. Also avoids race + # conditions in Rainbows! since load/require are not thread-safe + Unicorn.constants.each { |x| Unicorn.const_get(x) } + if defined?(Gem) && Gem.respond_to?(:refresh) logger.info "Refreshing Gem list" Gem.refresh -- cgit v1.2.3-24-ge0c7