Hey all.. I'm attempting to move some jvm args out...
# docker-commandbox
c
Hey all.. I'm attempting to move some jvm args out of server.json and into docker compose.. and in doing so, the luceedebug.jar is not being loaded BEFORE: server.json
Copy code
{
  "name": "myapp",
  "jvm": {
    "args": [
      "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=localhost:9999",
      "-javaagent:/app/lib/luceedebug.jar=jdwpHost=localhost,jdwpPort=9999,debugHost=0.0.0.0,debugPort=10000,jarPath=/app/lib/luceedebug.jar"
    ]
  }
}
AFTER: docker-compose.yml
Copy code
services:  
  myapp:
    image: myapp_commandbox-alpine
    build:
      context: .
      dockerfile: ./docker/commandbox/myapp/Dockerfile
    environment:
      ENVIRONMENT: "development"
      # commandbox settings
      BOX_SERVER_JVM_ARGS: "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=localhost:9999 -javaagent:/app/lib/luceedebug.jar=jdwpHost=localhost,jdwpPort=9999,debugHost=0.0.0.0,debugPort=10000,jarPath=/app/lib/luceedebug.jar"
I can see the BOX_SERVER_JVM_ARGS are loaded by commandbox...
Copy code
| √ | Overriding server.json values from env vars
   |   |----------------------------------------------------------
   |   | Overridding [JVM.ARGS] with OS environment variable [BOX_SERVER_JVM_A
   |   | RGS
But I'm expecting to see the output below, but there is no reference to luceedebug at all:
Copy code
Listening for transport dt_socket at address: 9999
[luceedebug] fs is case sensitive: true
[luceedebug] agent premain complete
...
CommandBox 5.8.0+00695
b
@chapmandu if you add verbose to the start, the full JVM args should show up in the console. Can you verify if they show up there>
c
I will do that Brad, FYI the jar is loaded as expected when the java arg is a single string or an array in server.json
Urm.. where would I add the
--verbose
flag when starting the docker container?
b
• server.json • env var
actually, come to think of it, I think it's on by default in our Docker containers
Just look at the console output, lol
c
Yes, I can see all the jvm args, I assumed verbose showed even more... ok so the values from BOX_SERVER_JVM_ARGS are not in the console output
Copy code
| Server start command: 
   |     /opt/java/openjdk/bin/java 
   |     -Djava.util.logging.config.file=/usr/lib/build/resources/text.log
   | ging.properties
   |     -Xmx1024m 
   |     -Xms256m 
   |     -cp /usr/lib/CommandBox/lib/runwar-4.8.3.jar runwar.Start 
   |     --background=false 
   |     --host 0.0.0.0 
   |     --stop-port 45267 
   |     --processname myapp [lucee 5.3.10+97] 
   |     --log-dir /app/.deploy/serverhome//logs 
   |     --server-name myapp 
   |     --tray-enable false 
   |     --dock-enable true 
   |     --directoryindex true 
   |     --timeout 240 
   |     --proxy-peeraddress false 
   |     --cookie-secure false 
   |     --cookie-httponly false 
   |     --pid-file /app/.deploy/serverhome//.pid.txt 
   |     --resource-manager-file-system-watcher=false 
   |     --log-pattern=[%p] %d{yyyy-MM-dd'T'HH:mm:ssXXX} %c - %m%n 
   |     --tray-icon /usr/lib/CommandBox/cfml/system/config/server-icons/t
   | rayicon-lucee.png
   |     --gzip-enable true 
   |     --logaccess-enable true 
   |     --logaccess-basename access 
   |     --logaccess-dir /app/.deploy/serverhome//logs 
   |     --cfengine-name lucee 
   |     -war /app/ 
   |     --web-xml-path /app/.deploy/serverhome//WEB-INF/web.xml 
   |     --http-enable true 
   |     --ssl-enable true 
   |     --ajp-enable false 
   |     --http2-enable true 
   |     --open-browser false 
   |     --open-url <https://0.0.0.0:443> 
   |     --port 8080 
   |     --ssl-port 443 
   |     --urlrewrite-enable true 
   |     --client-cert-trust-headers false 
   |     --urlrewrite-file /app/urlrewrite.xml 
   |     --predicate-file /app/.deploy/serverhome//.predicateFile.txt
   | Dry run specified, exiting without starting server.
   |------------------------------
   | √ | Overriding server.json values from env vars
   |   |----------------------------------------------------------
   |   | Overridding [JVM.ARGS] with OS environment variable [BOX_SERVER_JVM_A
   |   | RGS
   |   | Overridding [RUNWAR.ARGS] with OS environment variable [BOX_SERVER_RU
   |   | NWAR_ARGS
   |   | Overridding [APP.SERVERHOMEDIRECTORY] with OS environment variable [B
   |   | OX_SERVER_APP_SERVERHOMEDIRECTORY
   |   | Overridding [APP.CFENGINE] with OS environment variable [BOX_SERVER_A
   |   | PP_CFENGINE
   |   | Overridding [CFCONFIGFILE] with OS environment variable [BOX_SERVER_C
   |   | FCONFIGFILE
I'll see if I can dump them in the container.
Copy code
CommandBox> env show BOX_SERVER_JVM_ARGS
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=localhost:9999 -javaagent:/app/lib/luceedebug.jars=jdwpHost=localhost,jdwpPort=9999,debugHost=0.0.0.0,debugPort=10000,jarPath=/app/lib/luceedebug.jars
It appears CB is not using the BOX_SERVER_JVM_ARGS value
Copy code
2756b51161fc:/app# ps aux | grep java
    1 root      1:23 /opt/java/openjdk/bin/java -Djava.util.logging.config.file=/usr/lib/build/resources/text.logging.properties -Xmx1024m -Xms256m -cp /usr/lib/CommandBox/lib/runwar-4.8.3.jar runwar.Start --background=false --host 0.0.0.0 --stop-port 45267 --processname myapp [lucee 5.3.10+97] --log-dir /app/.deploy/serverhome//logs --server-name myapp --tray-enable false --dock-enable true --directoryindex true --timeout 240 --proxy-peeraddress false --cookie-secure false --cookie-httponly false --pid-file /app/.deploy/serverhome//.pid.txt --resource-manager-file-system-watcher=false --log-pattern=[%p] %d{yyyy-MM-dd'T'HH:mm:ssXXX} %c - %m%n --tray-icon /usr/lib/CommandBox/cfml/system/config/server-icons/trayicon-lucee.png --gzip-enable true --logaccess-enable true --logaccess-basename access --logaccess-dir /app/.deploy/serverhome//logs --cfengine-name lucee -war /app/ --web-xml-path /app/.deploy/serverhome//WEB-INF/web.xml --http-enable true --ssl-enable true --ajp-enable false --http2-enable true --open-browser false --open-url <https://0.0.0.0:443> --port 8080 --ssl-port 443 --urlrewrite-enable true --client-cert-trust-headers false --urlrewrite-file /app/urlrewrite.xml --predicate-file /app/.deploy/serverhome//.predicateFile.txt
b
Do you still have the jvm.args array in the server.json?
c
no, it was moved to the docker compose file
b
Dunno, then, I just tried running
Copy code
set BOX_SERVER_JVM_ARGS="-foo"
start --debug
in CommandBox and the server totally uses that arg 🤷
Copy code
Server start command:
   |     C:\Users\brad\.CommandBox\serverJREs\openjdk11_jre_x64_windows_hotspot_jdk-11.0.22+7\bin\java.exe
   |     -foo
c
Could it be the format of the BOX_SERVER_JVM_ARGS value?
b
maybe. You can debug what values CommandBox used when it started the server
Copy code
server info property=JVMargs
Copy code
server info property=JVMargsArray
c
Copy code
box server info property=JVMargsArray
[
    "-Djava.util.logging.config.file=/usr/lib/build/resources/text.logging.properties"
]
Hi @bdw429s, I tried your example
-foo
but it also is not showing in the console. The difference could be that I am setting the env var in the docker compose file. Commandbox has access to the variable after the container has started..
Copy code
env show BOX_SERVER_JVM_ARGS
-agentlib:jdwp=transport ... /luceedebug.jars
But it doesn't seem to load the luceedebug.jar when the BOX_SERVER_JVM_ARGS is set in the docker-compose file
Bump: I'm wondering if you might have been able to reproduce this using a docker-compose file? It seems simply moving the BOX_SERVER_JVM_ARGS from the server.jvm.args in server.json to docker-compose.yml is somehow stopping the commandbox from writing the value to the JVM args.
b
No idea, but it could be related to how the image is warmed up. You confirmed the env var is "visible" inside the running container, but if you're finalizing your docker images, the env var may not be present during the build. hard to say without seeing what's in your custom
./docker/commandbox/myapp/Dockerfile
. @jclausen may have some ideas as well. At the end of the day, CommandBox is just CFML code. Feel free to put in debugging in the part where it looks for that env var that prints out the console. It's the
loadOverrides()
function in the
ServerService
j
I have seen this issue before actually when trying to use a custom javagent or, like you are doing above, an agentlib. It seems to be hit or miss. I’ll take a look at whether it’s something the container startup is doing, but I don’t think so. The way I have worked around it for java agents in the past is to use the
JAVA_TOOL_OPTIONS
environment variable, but I’m not sure if that will blow up using the luceedebug jar.
c
Thanks @jclausen The JAVA_TOOL_OPTIONS variable is a good workaround.
👍 1