title: unicorn hangs saying Refreshing Gems
body: <p>I have a strange problem in staging after i migrated to unicorn from passenger.</p>
  
  <p>I configured unicorn for both development and staging environment . 
  its working in development but not in staging. In development its listening to 8080 where as in staging its listening to a unix socket. Will that make any diferrence ? Especially in production kinda env? </p>
  
  <p>This is what happens when i run it in staging </p>
  
  <ol>
  <li>It takes almost 100% CPU while starting</li>
  <li>sometimes it settles down and i am able to use it</li>
  <li>*But most of the times it hangs** and i had to kill it.</li>
  </ol>
  
  <p>I have logged a question regarding this issue <a href="https://stackoverflow.com/questions/6994321/unicorn-rails-takes-100-cpu-while-starting-in-production-mode">click here</a></p>
  
  <p>This is what i see in unicorn.stderr.log</p>
  
  <pre><code>I, [2011-08-26T09:02:53.324286 #5026]  INFO -- : unlinking existing socket=/home/krishnaprasad/project_name/tmp/sockets/unicorn.sock
  I, [2011-08-26T09:02:53.324502 #5026]  INFO -- : listening on addr=/home/krishnaprasad/project_name/tmp/sockets/unicorn.sock fd=3
  I, [2011-08-26T09:02:53.324860 #5026]  INFO -- : Refreshing Gem list
  </code></pre>
  
  <p>why does it try to refresh the gems ?
  is there any way to avoid it in config file ?</p>
  
  <p>this is what i have in config/unicorn_staging.rb</p>
  
  <pre><code># unicorn_rails -c /config/unicorn_staging.rb -E staging -D
  
  rails_env = 'staging'
  
  working_directory "/home/krishnaprasad/Projects/project_name"
  worker_processes 1
  preload_app true
  timeout 90
  
  rails_root = "/home/krishnaprasad/Projects/project_name"
  listen "#{rails_root}/tmp/sockets/unicorn.sock", :backlog =&gt; 2048
  
  pid "#{rails_root}/tmp/pids/unicorn.pid"
  stderr_path "#{rails_root}/log/unicorn.log"
  stdout_path "#{rails_root}/log/unicorn.log"
  
  GC.copy_on_write_friendly = true if GC.respond_to?(:copy_on_write_friendly=)
  
  before_fork do |server, worker|
    ActiveRecord::Base.connection.disconnect!
    old_pid = "#{Rails.root}/tmp/pids/unicorn.pid.oldbin"
    if File.exists?(old_pid) &amp;&amp; server.pid != old_pid
      begin
        Process.kill("QUIT", File.read(old_pid).to_i)
      rescue Errno::ENOENT, Errno::ESRCH
        # someone else did our job for us
      end
    end
  end
  
  after_fork do |server, worker|
    ActiveRecord::Base.establish_connection
  end
  </code></pre>
  
  <p>Any help highly appreciated.
  Thanks in advance</p>