(There's a post title I never thought I'd write)
If you have any Ruby web apps deployed with Puma (on Linux), you may have run in to the problem whereby there is no obvious way of bringing in Environment Variables before the Apps spin up. In a previous version of the Puma Jungle (system startup scripts for spinning up Puma apps [see here https://github.com/puma/puma/tree/master/tools/jungle/init.d]) there was a clear place to `source` a file before the App was launched.
This doesn't seem to exist in newer versions, so my dirty hack to get it working is:
- Put your dot file .my_app_vars_v1 in to the root of your web app
- Edit the file /usr/local/bin/run-puma
- Change the last line to read:
cd $app && . .*vars* && exec bundle exec puma -C $config 2>&1 >> $log
The addition of the
. .*vars* will "source" the file (the dot notation is a shorthand, terminal agnostic equivalent of "source")
The better solution would be to add an additional line in to the parser for /etc/puma.conf to specify a variables file, but that's for another day...