solo-io / squash

The debugger for microservices
https://squash.solo.io
Apache License 2.0
1.74k stars 103 forks source link

java: fallback on JAVA_OPTS env variable #171

Open mitchdraft opened 5 years ago

mitchdraft commented 5 years ago

Java port is not found when port is not included in the process invocation text

In such cases, it may be possible to get the needed text through the JAVA_PORT environment variable.

from slack discussion

{"level":"fatal","ts":1554974286.446306,"caller":"plank/main.go:27","msg":"debug failed!","error":"Can't find port in java command line arguments for PID: 7825, args: [/bin/sh -c /usr/start_tomcat_with_ddagent.sh ]","stacktrace":"main.main\n\t/workspace/gopath/src/github.com/solo-io/squash/cmd/plank/main.go:27\nruntime.main\n\t/usr/local/go/src/runtime/proc.go:201"}

note that the port is not included, just /bin/sh -c /usr/start_tomcat_with_ddagent.sh

however, the port is included in the JAVA_OPTS:

JAVA_OPTS: -javaagent:/usr/local/aspectjweaver-1.8.11.jar -Dcom.sun.management.jmxremote
    -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.port=9000
    -Dcom.sun.management.jmxremote.rmi.port=9000 -Dcom.sun.management.jmxremote.authenticate=false
    -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=127.0.0.1
    -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000 -Djava.net.useSystemProxies=true
    -Xmx3g
mitchdraft commented 5 years ago

if this strategy does not work, fallback to https://github.com/solo-io/squash/issues/172