How to Set Environment Variables for a CloudFoundry App
Join the DZone community and get the full member experience.
Join For FreeWe can set environment variables for an application that is deployed in CloudFoundry. For example if we want to pass a JAVA_OPTS environment variable with a value of -XX:MaxPermSize=256m. We have to use the env-add command of the vmc command-line tool. We specify the application name we want to set the environment variable for followed by a key=value pair.
In the following command we set a JAVA_OPTS environment variable for the website application:
$ vmc env-add website JAVA_OPTS="-XX:MaxPermSize=256m -XX:+CMSClassUnloadingEnabled" Adding Environment Variable [JAVA_OPTS="-XX:MaxPermSize=256m -XX:+CMSClassUnloadingEnabled"]: OK Stopping Application: OK Staging Application: OK Starting Application: OK $
To see which environment variables are set we can use the env command. To delete a variable we use env-del and the name of the environment variable.
$ vmc env website +-----------+----------------------------------------------------+ | Variable | Value | +-----------+----------------------------------------------------+ | JAVA_OPTS | -XX:MaxPermSize=256m -XX:+CMSClassUnloadingEnabled | +-----------+----------------------------------------------------+ $ vmc env-del website JAVA_OPTS Deleting Environment Variable [BLOG_OPTS]: OK Stopping Application: OK Staging Application: OK Starting Application: OK $
Published at DZone with permission of Hubert Klein Ikkink, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments