Simple program that reads .env
file and use it to run given command.
Never load environment variables manually or pollute your interpreter profile again.
.env
file in current directory.env
file:
.env
<COMMAND>
with generated environment variables
cargo install readenv
.env
file in with <KEY>=<VALUE>
structure.Run the app:
bash
renv <COMMAND>
During the run, the <COMMAND>
acts exactly as executed directly, including environment variables, stdin, stdout, stderr, pipelines support and signals handling.
Support of .env
file is provided by dotenv library. See its documentation for the format.
To run a Django project, a settings file is needed. One approach is to have different settings file per enviroment (e.g. for development and production).
The easiest way to do that is to define environment variable DJANGO_SETTINGS_MODULE
with name of the settings module.
Let's create .env
file (given settings module is local_settings
):
bash
echo 'DJANGO_SETTINGS_MODULE=local_settings' >> .env
Now run Django server with one command:
bash
renv django-admin.py runserver
12-factor App methodology is great but could be boring. A simple tool that automates work with environment variables would be helpful.
That tool should be a drop-in replacement for any app, so it:
SIGTERM
or SIGKILL
) identicallyAlso, it would be nice to:
Solution:
exec
in BASH)Thanks team of dotenv library for the most of work ;-)