I'm deploying my rails app with Capistrano. I want to save some API keys on the server as an environment variable. Those API keys should be accessible to my rails app that is deployed with Capistrano. Those API keys should also be accessible to a separate ruby file that is run as a daemon.
setting the API keys in environment variables seems like the ideal solution, however, I can't access them in my rails app with ENV["SOME_KEY"]
.
According to this post, because capistrano runs as non interactive and non login, ~/.bashrc
and ~/.bash_profile
are not loaded. The flowchart suggests that I should use $BASH_ENV
.
Can I just add my api keys in $BASH_ENV
and access them in my rails app and in the ruby file that is a daemon with ENV["SOME_KEY"]
?
I'm also thinking of just adding the api keys to a file somewhere on the server and symlinking it to the ruby file dir and rails dir and just open and reading it. Would this be possible?
See Question&Answers more detail:os