One of the tenants of the 12factor application is to store configuration in the environment. Often, for production environments, the environment is added as a .env file during the deploy. For many languages there are libraries to set this up from inside the application.
- This introduces a dependency
- Might be in the way when the rest of the application doesn't have to be loaded
- Not very unixy
In a shell, I often solve this by doing
env $(cat /where/my/application/is/.env | sed '/^#/d' | xargs). But lets be fair, no one
remembers that wants to type that much!
benv simply loads a
.env file into the environment and starts an application.
$ cargo install benv
$ git clone https://github.com/timonv/benv $ cd benv $ cargo build --release $ cp target/release/benv /somewhere/in/your/path
$ benv <dotenv> <program>... $ benv my/file echo $MYVARIABLE $ benv .env bundle exec rails $ benv .env cargo run $ benv .env npm start $ benv .env mix phoenix.server $ benv .env my_binary And so on!
benv --help for more options.
Current benv has to keep running (there should be little overhead). Using libc to properly daemonize is on the wishlist.
- Pull Request :-)