We have gathered a list of the most common configurations for you
Java CLI
Setuping the Java Agent is possible for various configurations according to the deployment model of your Application Under Test.
When starting your application under test using a CLI command, you need to specify the Sealights agent as part of the command. The following snippet shows the command after integrating Sealights, but for your convenience, we've added a reference to the command before Sealights integration:
In some environments, the startup is deeply nested in scripts and the command line is not accessible to start the application with the necessary command-line options. In these environments, the environment variable can be useful to augment a command line as it allows you to specify the initialization of tools, specifically the launching of agents using the -javaagent options.
Most common variables are JAVA_OPTS, JAVA_OPTIONS and JAVA_TOOL_OPTIONS. For example:
Setting the JAVA_TOOL_OPTIONS will affect every JVM that runs on the machine. If you want to only have our agent run with a specific JVM, then you shouldn't use this option and prefer a more specific environment variable like JAVA_OPTS, JAVA_OPTIONS etc...
JAVA_TOOL_OPTIONS is limited to 1024 characters and adding parameters above this buffer size will cause java to ignore it completely.
Video Walkthrough: Agent Configured for Java CLI
Tomcat
The CATALINA_OPTS environment variable is used to pass configuration flags and system properties to the JVM that runs specifically the Tomcat server.
Since Sealights Agent is usually in use only by Tomcat, you'll be best advised to use theCATALINA_OPTS variable, whereas if you put your settings in JAVA_OPTS, it will be used locally by other Java applications as well.
Both options are compatible with Sealights.
If you are running Tomcat from the command line, you can just set the environment variable, either from the command line or by updating the setenv.sh (or setenv.bat in windows)
Tomcat recommends using a setenv script to specify environment variables. You can learn more about the setenv script, including how to find or create it as needed, by consulting RUNNING.txt, which is included with every distribution of Tomcat.
Tomcat as a Service
If you are running Tomcat as a service on Linux, you will need to update the service file itself under /etc/init.d or any other startup script you have set up for the service.
Another option is to update the setenv.sh (setenv.bat on Windows) and update the JVM parameters inside it.
There are three ways to configure your application when running as a Windows Service:
Start Tomcat9 with //MS//ServiceName to get an icon in the system tray which gives you quick access to the configuration of the service.
Write a script that edits the config for you using a command like tomcat9 //US//... . This way, you can save the config somewhere for backup or update dynamically your server from a CI/CD script.
You can refer to the official Tomcat documentation page for more details and options. For example, the command may look like
tomcat9 //US//MyService --JvmOptions='-javaagent:/sealights/sl-cd-agent.jar -Dsl.tags=tomcat -Dsl.labId=<lab ID> [...]'
Docker/Container
Below are two ways of configuring the Java agent with Dockers: by customizing the DockerFile or via Docker Compose environment setup.
DockerFile
The container image contains the Sealights agent by default.
FROM gradle:7.6.0-jdk11-alpine AS gradleCOPY ./src src/COPY ./settings.gradle settings.gradleCOPY ./build.gradle build.gradleRUN gradle clean buildFROM amazoncorretto:11-alpine-jdkRUN mkdir /opt/appWORKDIR /opt/app# Copy built spring applicationCOPY --from=gradle /home/gradle/build/libs/calculator-0.0.1-SNAPSHOT.jar ./calculator.jar# Download the agent - it should be copied to separate image and used with Docker's "FROM" commandRUN wget -nv https://agents.sealights.co/sl-cd-agent/sl-cd-agent-latest.zipRUN unzip -oq sl-cd-agent-latest.zipRUN echo "Sealights CD Agent version used is: $(cat version.txt)"# Copy run scriptCOPY --chmod=777 ./scripts/run_app.sh run_app.shEXPOSE 8080WORKDIR /opt/appCMD ["/opt/app/run_app.sh", "calculator.jar"]
The entry point includes the Selaights JVM parameters to make sure it is kept active if the container is restarted
#!/bin/sh## The variables are set environment level.# SL_TOKEN=token# SL_LAB_ID=a# SL_BUILD_NAME=b# DEBUG=-Dsl.httpDebugLog=yes# LOGGING=-Dsl.log.toConsole=true# PACKAGES="i0.sealights.demo.calculator*"java-Dsl.log.level=DEBUG"$DEBUG $LOGGING" \-Dsl.workspace=. \-Dsl.tags=$1,cdagent,container \-Dsl.includes="$PACKAGES" \-Dsl.token="$SL_TOKEN" \-Dsl.labId="$SL_LAB_ID" \-Dsl.buildName="$SL_BUILD_NAME" \-Dsl.appName="$CALC_APPNAME" \-javaagent:./sl-cd-agent.jar \-jar $1
Docker Compose
Typically, you can set up the agent specifically for your testing environment, by mounting the folder containing the agent, and its token, and injecting it as a -javaagent via the environment variables defined globally.
A sample to use ${BUILD_NAME} dynamically is to set it in the .env file:
BUILD_NAME=weaveworksdemos/queue-master:0.3.1
Kubernetes
In the sample YAML file below, the agent is downloaded to a specific folder (/download/sl-cd-agent.jar) mounted to the K8s container in a dedicated volume (/sealights). The agent is then enabled via the JVM_TOOLS_OPTIONS variable set specifically for this configuration & environment ensuring the default configuration of the container is not modified.
FROM alpine:3.17.0ADD sl-cd-agent.jar /download/sl-cd-agent.jar
JBoss/Wildfly
When the application server is JBoss or WildFly, you should also update the following parameters: jboss.modules.system.pkgs=org.jboss.byteman,io.sealights
All rights reserved to Sealights Technologies ltd.
Open the service manager in the "Control Panel". There is an entry for Tomcat. In the editor, there is a tab where you can add additional JVM parameters (See screenshot below)