after_fork and redis
fingermark at gmail.com
Mon Oct 1 15:31:07 UTC 2012
I'm using unicorn w/ a rails app. I have the following in my
environment.rb $redis = MyApplication::Application.config.redis and in
production.rb I have config.redis = Redis.new(host: "localhost").
I've read I'm supposed to $redis = Redis.new(host: "localhost") in
after_fork when preload_app is true.
When I don't do this, each worker/pid seems to have their own redis
instance. So, why is this needed? Here's the logs of me printing out
$redis.client.inspect when both $redis = Redis.new in the after_fork
and just $redis = Redis.new in the environment.rb.
No after fork
The only thing different I notice is Connection::TCPSocket:fd is
always 13 w/ the after fork.
More information about the mongrel-unicorn