On Tuesday, December 4, 2012 at 9:19 PM, Peter Hall wrote:
> Hi,
> 
> I'm trying to use unicorn in a test deployment of a Rails app that
> uses Mongoid, so Activerecord isn't included in the app. When I start
> unicorn through Capistrano though, the stderr log fills up endlessly
> with identical ActiveRecord-related errors:
> 
> I, [2012-12-05T04:19:25.375952 #5096] INFO -- : Refreshing Gem list
> I, [2012-12-05T04:19:32.941249 #5096] INFO -- : listening on
> addr=/var/www/webapps/fugu-cp/shared/pids/unicorn.sock fd=11
> I, [2012-12-05T04:19:32.990825 #5096] INFO -- : master process ready
> E, [2012-12-05T04:19:33.108183 #5110] ERROR -- : uninitialized
> constant ActiveRecord (NameError)
> /var/www/webapps/fugu-cp/current/config/unicorn.rb:68:in `block in reload'
> /var/www/webapps/fugu-cp/shared/bundle/ruby/1.9.1/gems/unicorn-4.4.0/lib/unicorn/http_server.rb:569:in
> `call'
> /var/www/webapps/fugu-cp/shared/bundle/ruby/1.9.1/gems/unicorn-4.4.0/lib/unicorn/http_server.rb:569:in
> `init_worker_process'
> /var/www/webapps/fugu-cp/shared/bundle/ruby/1.9.1/gems/unicorn-4.4.0/lib/unicorn/http_server.rb:593:in
> `worker_loop'
> /var/www/webapps/fugu-cp/shared/bundle/ruby/1.9.1/gems/unicorn-4.4.0/lib/unicorn/http_server.rb:491:in
> `spawn_missing_workers'
> /var/www/webapps/fugu-cp/shared/bundle/ruby/1.9.1/gems/unicorn-4.4.0/lib/unicorn/http_server.rb:141:in
> `start'
> /var/www/webapps/fugu-cp/shared/bundle/ruby/1.9.1/gems/unicorn-4.4.0/bin/unicorn_rails:209:in
> `<top (required)>'
> /var/www/webapps/fugu-cp/shared/bundle/ruby/1.9.1/bin/unicorn_rails:23:in 
> `load'
> /var/www/webapps/fugu-cp/shared/bundle/ruby/1.9.1/bin/unicorn_rails:23:in
> `<main>'
> 
> This repeats until I kill Unicorn.
> 
> If you're curious, the way I'm starting Unicorn in the deploy file is
> as follows:
> 
> set :unicorn_rails, "#{deploy_to}/shared/bundle/ruby/1.9.1/bin/unicorn_rails"
> run "cd #{latest_release} && bundle exec \"#{unicorn_rails} -c
> #{deploy_to}/current/config/unicorn.rb -D -E #{rails_env}\""
> 
> Incidentally, if there's a standard Unicorn include file for
> Capistrano so I don't have to specify my own tasks to start and stop
> it, I'd be grateful to know, because I couldn't find one and had to
> use a very heavily-modified version of something I copied+pasted from
> this gist: https://gist.github.com/1003099
> 
> Thanks,
What's L68 of your config/unicorn.rb file look like? Check to see if you have 
copied/pasted a line that references ActiveRecord in the before_fork or 
after_fork blocks.

A lot of unicorn examples have an ActiveRecord::Base.connection.disconnect! 
(with a defined?(ActiveRecord::Base) but that might not be present in your 
config) statement to ensure that AR connections aren't shared between the 
master and worker processes. 
_______________________________________________
Unicorn mailing list - [email protected]
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

Reply via email to