Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for loading environment variables from optional file #80

merged 1 commit into from Nov 19, 2016


Copy link

@jessecarbon jessecarbon commented Nov 8, 2016

It's common to want to load environment variables from an external file for a service upon startup. The common location for these for SysV scripts is /etc/sysconfig/$service_name. Some examples: docker, Graylog, nginx, elasticsearch.

For systemd unit files, there's an option called EnvironmentFile. Example: elasticsearch.

Both of these additions are only applied if the files exist. I've tested both of them on CentOS 6 and 7, respectively. The systemd EnvironmentFile can always be added after the fact with a drop-in, but i added it here for consistency. If it should be excluded, I can edit the PR. For SysV scripts however, there's not really another good way to inject environment variables.

Copy link
Contributor Author

@jessecarbon jessecarbon commented Nov 8, 2016

I just realized that debian actually uses /etc/default/$service_name instead of /etc/sysconfig/$service_name. Without maintaining separate templates for rpm/deb distros, I could add a secondary check for that file. Please let me know your thoughts.

@kardianos kardianos merged commit 6d3a0ee into kardianos:master Nov 19, 2016
Copy link

@kardianos kardianos commented Nov 19, 2016

Supporting debian would be nice. Please issue a PR when you get a chance.

jessecarbon added a commit to jessecarbon/collector-sidecar that referenced this pull request Dec 2, 2016
jessecarbon added a commit to jessecarbon/collector-sidecar that referenced this pull request Dec 2, 2016
mariussturm added a commit to Graylog2/collector-sidecar that referenced this pull request Dec 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.