Detecting unicorn / defining after_fork after master startup

Matt Sanders matt at modal.org
Thu Jul 19 22:43:58 UTC 2012


Hey everyone,

Working on an engine for rails that needs specialized behavior with
forking and I had a couple questions.

1. What is the best way to determine whether the app is indeed running
inside a unicorn server?

Most of the attempts I can find to detect check to see if the main
modules for Unicorn are defined, but this really only checks to see
that Unicorn is present, not that you are using it. I know a lot of
shops may use Unicorn in production but something else for local
development. Is there something equivalent to the IN_PHUSION_PASSENGER
constant that passenger defines?

2. Is there an established way for adding an after_fork hook after
Unicorn has already started up?

I'm aware of the ability to do this via the config file but I don't
want my users to have to add something to their unicorn config file.
Is there an equivalent to passenger's
PhusionPassenger.on_event(:starting_worker_process) method?

Thanks!
-Matt


More information about the mongrel-unicorn mailing list