-
Notifications
You must be signed in to change notification settings - Fork 25
Set environment variables for your application
As the Qanary core components are implemented in Java using the Spring Boot framework and provided with a Docker configuration, the standard options for these technologies for changing runtime parameters (environment parameters, custom system settings) are also applicable here.
While running your Qanary application directly via Java, provides you some standard Java mechanisms to easily set specific values for environment variables.
You can change the existing values or add new environment variables in the file application.properties
.
After re-compiling your application, the new values are available.
In the Qanary pipeline, the file is available in the folder src/main/resources/
.
In Qanary components, typically the equivalent files are stored in the folder src/main/resources/config
.
More Information about the behavior of application.properties
in Spring Boot is available here.
In our Qanary pipeline implementation, an additional file applications.local.properties
is defined where you can define new values.
The usage is the same as in the application.properties
.
However, the values in applications.local.properties
are always overwriting possible existing values of the file application.properties
.
As in any Java application, you can set environment variables on the shell, which will overwriting existing values.
Let’s assume you want to set the log level of logging.level.org.springframework.web
to ERROR
.
In this case, you need to set the environment variables using the uppcase-and-underscore format.
For logging.level.org.springframework.web
on a Linux OS it would be:
export LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_WEB=ERROR
Thereafter, start your application as usual.
Additional information can be found here.
You can also pass variables directly to your application during the start of the Java JAR file.
Let’s assume you want to set the log level of logging.level.org.springframework.web
to ERROR
.
In this case, use the -D
parameter.
For example:
java -Dlogging.level.org.springframework.web=ERROR ...
More information is available here.
Running your Qanary system inside of Docker containers is very useful. Passing environment variables is very similar to your Docker containers can be done using the following methods.
The following command would start a Docker container while passing a value to the Docker-internal system (same example as before).
docker run --env LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_WEB=ERROR ...
More details are available here.
You can also use an env
file to collect all relevant value at once (cf. here).
See the documentation.
-
How to establish a Docker-based Qanary Question Answering system
-
How to implement a new Qanary component
... using Java?
... using Python (Qanary Helpers)?
... using Python (plain Flask service)?