Environment variables represent a kind of placeholders, where you can store the frequently used parameters values or strings in order not to specify them manually in the code each time they are needed. There is a number of default environment variables which are preconfigured and can be used in your application code or even adjusted before node creation to apply some customization, making your work with CirrusGrid PaaS even more convenient.
In this guide, we’ll describe the most common ways of adding your custom variables for any node within platform:
1. Hover over the node group in dashboard, expand the Additionally list and select the Variables options.
2. Within the opened frame, you can adjust a list of environment variables up to your needs (using the buttons at the tools pane).
Note: CirrusGrid implementation of the Docker containers allows usage of the existing environment variables to define others. For example, the MY$HOME value will be automatically converted to MY\ one (or similar based on the HOME variable value).
Don’t forget to Apply the changes you’ve made.
You are able to provide your custom variables using the shell config files:
In order to help you with maintaining these files, CirrusGrid automatically include the sources of the .bashrc config within .bash_profile. In such a way, you can provide custom variables through the former file only:
1. Establish SSH connection to your container. For example, we’ll use the embedded Web SSH client:
2. Create or adjust the .bashrc file within the home directory by adding your custom variables in the following format:
export {var_name}= {var_value}
where
3. Now, each new bash instance will be provided with your custom variables. To force new settings appliance for the current session, just refresh the sources with the command shown below. Next, verify new variables availability:
source ~/.bashrc echo $ {var_name}
As you can see, the changes were successfully applied.
The following simple workflow is identical for all of the CirrusGrid-managed Java application servers.
1. Click the Config button for your application server to access container file manager.
2. In the opened tab, navigate to the variables.conf file within one of the following locations:
3. Here, you can provide your custom variables (each one should be separated by space or start from a new line) or adjust Java options for your application. For example:-Dvar1=value1 -Dvar2=value2-Dmy.var3=/my/value
Tip: Alternatively, some of the application servers (i.e. GlassFish, Payara, WildFly) are provided with admin panel, which also allows to add JVM options and custom variables:
Do not forget to Save the configurations you’ve made.
4. Restart nodes of your application server to apply changes.
5. The new variables can be called through your Java code with the help of the System.getProperty(“your_variable”) method to appoint the specified values to the needed arguments. For example:
Now, you can adjust your application code using these new variables.
Powered by BetterDocs
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.