I'm trying to make a change to my Unicorn config file, along the lines suggested by these three links, to alter the Unicorn logging:
They all follow the same sort of pattern (I'm trying the first one), but when I add them to my config I get the same message repeated over and over by Unicorn:
ERROR -- : uninitialized constant Unicorn::Configurator::Rails (NameError)
The stack trace points to the first use of Rails in the Unicorn log file. What am I doing it wrong, or what do I need to change to get those snippets to work?
I am using Rails 3.2.14, and invoking my server using:
bundle exec unicorn -c config/unicorn.rb
Using unicorn_rails instead of unicorn makes no difference (same error). My config looks like this:
worker_processes 20
listen ".../unicorn.socket", :backlog => 64
timeout 30
pid ...
stderr_path ...
stdout_path ...
GC.respond_to?(:copy_on_write_friendly=) and
GC.copy_on_write_friendly = true
check_client_connection false
before_fork do |server, worker|
# No code
end
after_fork do |server, worker|
defined?(ActiveRecord::Base) and
ActiveRecord::Base.establish_connection
# Snippet from the links above, error occurs within here
if defined?(ActiveSupport::TaggedLogging) && Rails.logger.kind_of?(ActiveSupport::TaggedLogging)
...
end
end
You need to set preload_app true in your config for the gems like Rails to be accessible from the config file - see here for the documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With