Add after_worker_ready configuration optionchroot
commitd322345251e15125df896bb8f0a5b53b49a1bf3f
authorJeremy Evans <code@jeremyevans.net>
Wed, 22 Feb 2017 00:33:09 +0000 (21 16:33 -0800)
committerEric Wong <e@80x24.org>
Thu, 23 Feb 2017 20:23:44 +0000 (23 20:23 +0000)
treebe7fce006c6170539f12c7c1b6095edb351f6f5b
parentd4e0ced16710e456cd192784ab106091568ebde3
Add after_worker_ready configuration option

This adds a hook that is called after the application has
been loaded by the worker process, directly before it starts
accepting requests.  This hook is necessary if your application
needs to gain access to resources during initialization,
and then drop privileges before serving requests.

This is especially useful in conjunction with chroot support
so the app can load all the normal ruby libraries it needs
to function, and then chroot before accepting requests.

If you are preloading the app, it's possible to drop privileges
or chroot in after_fork, but if you are not preloading the app,
the only way to currently do this is to override the private
HttpServer#init_worker_process method, and overriding private
methods is a recipe for future breakage if the internals are
modified.  This hook allows for such functionality to be
supported and not break in future versions of Unicorn.
lib/unicorn/configurator.rb
lib/unicorn/http_server.rb