Is there a utility to read environment variables from an env file and then run a command (more lightweight than foreman)?
You can source the environment file in the active shell and run the program:
sh -ac ' . ./.env; /usr/local/bin/someprogram'
The -a
switch exports all variables, so that they are available to the program.
Another alternative is envdir
:
envdir runs another program with environment modified according to files in a specified directory.
- The daemontools original: http://cr.yp.to/daemontools/envdir.html
- A python port: https://github.com/jezdez/envdir
I tried source .env
and it worked like a charm. Unfortunately, none of the other solutions posted here worked for me.