Skip to content

Read and set environmental variables for processes from Consul.

License

Notifications You must be signed in to change notification settings

Cloudxtreme/envconsul

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

envconsul

envconsul sets environmental variables for processes by reading them from Consul's K/V store.

envconsul allows applications to be configured with environmental variables, without having to be knowledgable about the existence of Consul. This makes it especially easy to configure applications throughout all your environments: development, testing, production, etc.

envconsul is inspired by envdir in its simplicity, name, and function.

Download & Usage

Download a release from the releases page. Run envconsul to see the usage help:


$ envconsul
Usage: envconsul.exe [options] prefix child...

  Sets environmental variables for the child process by reading
  K/V from Consul's K/V store with the given prefix.

Options:

  -addr="127.0.0.1:8500": consul HTTP API address with port
  -dc="": consul datacenter, uses local if blank
  -errexit=false: exit if there is an error watching config keys
  -reload=false: if set, restarts the process when config changes
  -sanitize=false: turn invalid characters in the key into underscores
  -upcase=false: make all environmental variable keys uppercase

Example

We run the example below against our NYC demo server. This lets you set keys/values in a public place to just quickly test envconsul. Note that the demo server will clear the k/v store every 30 minutes.

After setting the prefix/FOO key to "bar" on the demo server, we can see it work:

$ envconsul -addr="nyc1.demo.consul.io:80" prefix env
FOO=bar

We can also ask envconsul to watch for any configuration changes and restart our process:

$ envconsul -addr="nyc1.demo.consul.io:80" -reload=true \
  prefix /bin/sh -c "env; echo "-----"; sleep 1000"
FOO=bar
-----
FOO=baz
-----
FOO=baz
BAR=foo
-----

The above output happened by setting keys and values within the online demo UI while envconsul was running.

About

Read and set environmental variables for processes from Consul.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 96.8%
  • Makefile 3.2%