Skip to content

problem with initializer in prod(unicorn), though works fine in dev(brick) #15

Closed
ghost opened this Issue Aug 21, 2012 · 3 comments

1 participant

@ghost
ghost commented Aug 21, 2012

Version: 0.4.0 beta

Trace follows

I, [2012-08-21T03:03:26.464987 #29616]  INFO -- : Refreshing Gem list
E, [2012-08-21T03:03:33.700140 #29613] ERROR -- : uninitialized constant ContactUs (NameError)
/home/deployer/apps/portfoliolimits/releases/20120821070056/config/initializers/contact_us.rb:2:in `<top (required)>'
/home/deployer/apps/portfoliolimits/shared/bundle/ruby/1.9.1/gems/railties-3.2.7/lib/rails/engine.rb:588:in `block (2 levels) in <class:Engine>'
/home/deployer/apps/portfoliolimits/shared/bundle/ruby/1.9.1/gems/railties-3.2.7/lib/rails/engine.rb:587:in `each'
/home/deployer/apps/portfoliolimits/shared/bundle/ruby/1.9.1/gems/railties-3.2.7/lib/rails/engine.rb:587:in `block in <class:Engine>'
/home/deployer/apps/portfoliolimits/shared/bundle/ruby/1.9.1/gems/railties-3.2.7/lib/rails/initializable.rb:30:in `instance_exec'
/home/deployer/apps/portfoliolimits/shared/bundle/ruby/1.9.1/gems/railties-3.2.7/lib/rails/initializable.rb:30:in `run'
/home/deployer/apps/portfoliolimits/shared/bundle/ruby/1.9.1/gems/railties-3.2.7/lib/rails/initializable.rb:55:in `block in run_initializers'
/home/deployer/apps/portfoliolimits/shared/bundle/ruby/1.9.1/gems/railties-3.2.7/lib/rails/initializable.rb:54:in `each'
/home/deployer/apps/portfoliolimits/shared/bundle/ruby/1.9.1/gems/railties-3.2.7/lib/rails/initializable.rb:54:in `run_initializers'
/home/deployer/apps/portfoliolimits/shared/bundle/ruby/1.9.1/gems/railties-3.2.7/lib/rails/application.rb:136:in `initialize!'
/home/deployer/apps/portfoliolimits/shared/bundle/ruby/1.9.1/gems/railties-3.2.7/lib/rails/railtie/configurable.rb:30:in `method_missing'
/home/deployer/apps/portfoliolimits/releases/20120821070056/config/environment.rb:5:in `<top (required)>'
config.ru:4:in `require'
config.ru:4:in `block in <main>'
/home/deployer/apps/portfoliolimits/shared/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval'
/home/deployer/apps/portfoliolimits/shared/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize'
config.ru:1:in `new'
config.ru:1:in `<main>'
/home/deployer/apps/portfoliolimits/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/lib/unicorn.rb:44:in `eval'
/home/deployer/apps/portfoliolimits/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/lib/unicorn.rb:44:in `block in builder'
/home/deployer/apps/portfoliolimits/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/lib/unicorn/http_server.rb:696:in `call'
/home/deployer/apps/portfoliolimits/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/lib/unicorn/http_server.rb:696:in `build_app!'
/home/deployer/apps/portfoliolimits/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/lib/unicorn/http_server.rb:569:in `init_worker_process'
/home/deployer/apps/portfoliolimits/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/lib/unicorn/http_server.rb:589:in `worker_loop'
/home/deployer/apps/portfoliolimits/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/lib/unicorn/http_server.rb:487:in `spawn_missing_workers'
/home/deployer/apps/portfoliolimits/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/lib/unicorn/http_server.rb:498:in `maintain_worker_count'
/home/deployer/apps/portfoliolimits/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/lib/unicorn/http_server.rb:272:in `join'
/home/deployer/apps/portfoliolimits/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/bin/unicorn:121:in `<top (required)>'
/home/deployer/apps/portfoliolimits/shared/bundle/ruby/1.9.1/bin/unicorn:23:in `load'
/home/deployer/apps/portfoliolimits/shared/bundle/ruby/1.9.1/bin/unicorn:23:in `<main>'
@JDutil
Owner
JDutil commented Aug 22, 2012

I don't think using Unicorn as the web server in Production would make a difference over your development setup. I would ensure your deployment is doing a bundle install, and using bundle exec when starting Unicorn.

The issue is that the gem is not being loaded for you as it should be before trying to initialize Rails.

@ghost
ghost commented Aug 22, 2012

You are right that the gem is not loaded, even though I had run bundle install and restarted unicorn. The problem is with unicorn that requires to be restarted with:

  /etc/init.d/unicorn_epub stop
  /etc/init.d/unicorn_epub start

Doing this forces unicorn to load the gem; the standard capistrano restart does not do it...

I found today another issue that looked similar (ryanb/cancan#674) and verified that it works.

Thanks for taking the time.

@ghost ghost closed this Aug 22, 2012
@JDutil
Owner
JDutil commented Aug 23, 2012

Glad you worked it out. Let me know if you run into any other issues.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.