Hi,
For some time I've been using Unicorn to serve Rails applications.
I've been increasingly relying on environment variables to set various
password and configuration bits outside of the application's code.
For that I've been using the "dotenv" gem that load a `.env` file into
the ENV hash. It's great and really useful in development mode, but
it's not a best practice to use it in production. Here is what Brandon
Keepers (maintainer of Dotenv) says about this :
> One of the reasons I don't advocate for using dotenv in production is because
> it loads the environment variables within the ruby process, which makes it
> very difficult to track which variables were previously set and which were
> loaded by dotenv. If you set these variables in the environment of your
> server (/etc/environment, /etc/profile, etc) then unicorn reloading will just
> work.
So I was wondering what would be the correct way to have environment
variables available in the Ruby process, up-to-date when the Unicorn
process is started and reloaded too (with USR2).
And there is also the case of various shell initializations
(login/non-login, interactive/non-interactive) and supervisors like
Monit that strip the environment to a minumum before executing the
start/stop commands.
I understand that I can do something like this on start :
$ source ~/my/app/.env && unicorn [...]
But what about the reload situation ?
Thanks for the help.
--
Jérémy Lecour :
http://jeremy.wordpress.com - http://twitter.com/jlecour