app benv

Load env files for an application without the dependency

4 releases

Uses old Rust 2015

0.1.3 Feb 1, 2016
0.1.2 Nov 26, 2015
0.1.1 Nov 9, 2015
0.1.0 Nov 6, 2015

Custom license

10KB
225 lines

Benv

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.

However:

  • 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!

Meet B(etter)env. benv simply loads a .env file into the environment and starts an application.

Installation

Via Cargo:

$ cargo install benv

From source:

$ git clone https://github.com/timonv/benv
$ cd benv
$ cargo build --release
$ cp target/release/benv /somewhere/in/your/path

Usage

$ 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!

See benv --help for more options.

Caveats

Current benv has to keep running (there should be little overhead). Using libc to properly daemonize is on the wishlist.

Contributing

  1. Fork
  2. Code
  3. Test
  4. Pull Request :-)

Dependencies

~4MB
~85K SLoC