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
merged 1 commit into from Nov 19, 2016

Conversation

Projects
None yet
2 participants
@jessecarbon
Contributor

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.

@jessecarbon

This comment has been minimized.

Contributor

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

@kardianos

This comment has been minimized.

Owner

kardianos commented Nov 19, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment