This manual allows you to implement the functionality of runtime class redefinition using Dynamic Code Evolution Virtual Machine (DCEVM) and Hotswap Agent.
To provide hot reload functionality for the openlmis microservice, follow these steps:
In the Dockerfile in a specific microservice (e.g. stockmanagement), change the service-base version to v6.1-dcevm.
FROM openlmis/service-base:6.1-dcevm
Add the hotswap-agent.properties file to the resources folder containing the following properties:
autoHotswap=true
extraClasspath=${extra.class.path}
disabledPlugins=${disabled.plugins}Build a docker image of the microservice (use commands:
docker-compose -f docker-compose.builder.yml run builder and
docker-compose -f docker-compose.builder.yml build image).In the docker-compose.yml file in ref-distro, add the following properties for the microservice:
environment: JAVA_OPTS: "-XXaltjvm=dcevm -agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=n -Ddisabled.plugins=Proxy -javaagent:/opt/hotswap-agent/hotswap-agent.jar=autoHotswap=true -Dextra.class.path=/extra_class_path" volumes: - (APP_PATH)/build/classes/java/main:/extra_class_path
*(APP_PATH) is the path to the application on your system. For example:
Start the application (run: docker-compose -f docker-compose.yml up --build --remove-orphans --force-recreate command or start-local.sh)
After making changes to the code, use the command:
docker-compose -f docker-compose.builder.yml run builder
to trigger HotSwapAgent and deliver changes to the running container. To speed up the reload process, you can add options to the build.sh file that allow you to skip some steps included in the builder, e.g. -x test -x integrationTest.