This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-starter.git
The following commit(s) were added to refs/heads/master by this push:
new 7054206 SLING-12031 - Allow auto-launch of Java agents for the
container image (#236)
7054206 is described below
commit 705420630579652acefe71bb5bdb6229f58ef30a
Author: Robert Munteanu <[email protected]>
AuthorDate: Wed Sep 20 22:06:04 2023 +0200
SLING-12031 - Allow auto-launch of Java agents for the container image
(#236)
---
Dockerfile | 1 +
src/main/container/bin/launch.sh | 9 ++++++++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/Dockerfile b/Dockerfile
index 42b8921..95df7cd 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -27,6 +27,7 @@ RUN groupadd --system sling && \
mkdir /opt/sling/org.apache.sling.feature.launcher && \
mkdir /opt/sling/launcher && \
mkdir /opt/sling/artifacts && \
+ mkdir /opt/sling/agents && \
chown -R sling:sling /opt/sling/launcher
VOLUME /opt/sling/launcher
diff --git a/src/main/container/bin/launch.sh b/src/main/container/bin/launch.sh
index 9f49219..002c7b2 100755
--- a/src/main/container/bin/launch.sh
+++ b/src/main/container/bin/launch.sh
@@ -37,8 +37,15 @@ if [ ! -z "${JAVA_DEBUG_PORT}" ]; then
JAVA_DEBUG_OPTS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:${JAVA_DEBUG_PORT}"
fi
# remove add-opens after SLING-10831 is fixed
-export JAVA_OPTS="--add-opens java.base/java.lang=ALL-UNNAMED
${JAVA_DEBUG_OPTS} ${EXTRA_JAVA_OPTS}"
+JAVA_OPTS="--add-opens java.base/java.lang=ALL-UNNAMED ${JAVA_DEBUG_OPTS}
${EXTRA_JAVA_OPTS}"
+agents=$(find agents -name "*.jar")
+for agent in ${agents}; do
+ echo "[INFO] Discovered agent ${agent}"
+ JAVA_OPTS="-javaagent:${agent} ${JAVA_OPTS}"
+done
+
+export JAVA_OPTS
echo "[INFO] JAVA_OPTS=${JAVA_OPTS}"
exec org.apache.sling.feature.launcher/bin/launcher \