Skip to content

Environment variables for config options #217

@ibnesayeed

Description

@ibnesayeed

Is there a way to set certain config option using environment variables? There are cases when it can be handy to pass some environment variables instead of making changes to the config files such as:

  • In testing or development environments we want to run the instance with different configs frequently.
  • In production environments if we want to run multiple instances on different hosts/ports and load balance then we will have to duplicate config files with very little differences.
  • When the application is deployed for the first time using .war file, there is no way to overwrite the defaults unless the config files are modified and the and the application is reloaded by restarting Tomcat.

Here is an example of some configs from the wayback.xml file:

wayback.basedir=/tmp/openwayback
wayback.url.scheme=http
wayback.url.host=localhost
wayback.url.port=8080

I understand that XML files cannot load environment variables, but when these config options are loaded in Java files, at that time respective environment variables can take precedence if present otherwise fallback to the values set in the config files. Here is a pseudo example to illustrate the usage:

wayback.url.port = env["wayback-url-port"] || conf["wayback.url.port"] || 8080

I was deploying Wayback suing Docker Container and I wished this functionality was there.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions