Saturday, October 22, 2016

Set Environment Variables When Wildfly Is Run As A Service

If you are running wildfly server as a service under GNU/Linux, setting environment variables under profile.d, bash_rc etc won't be read. In order for your war to get the environment variable follow the below steps. Say the variable is APP_PROPERTIES and the path is /opt/config/app.properties.
# Add the following line in /etc/default/wildfly.conf
APP_PROPERTIES="/opt/config/app.properties"
# export the variable in /etc/init.d/wildfly
export APP_PROPERTIES