Skip to content

Commit

Permalink
Add JRebel lib to glassfish-dev. Add init script to enable JRebel, JD…
Browse files Browse the repository at this point in the history
…WP and/or JXM. #101 #124
  • Loading branch information
poikilotherm committed Jan 20, 2020
1 parent fd41ade commit 10e5f3b
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docker/dataverse-k8s/glassfish-dev/Dockerfile
Expand Up @@ -19,9 +19,18 @@ RUN mvn package -DskipTests
FROM iqss/dataverse-k8s
LABEL maintainer="FDM FZJ <forschungsdaten@fz-juelich.de>"

ENV JREBEL_LIB=/opt/dataverse/jrebel/lib/libjrebel64.so
RUN wget --no-verbose -O "${HOME_DIR}/jrebel.zip" http://dl.zeroturnaround.com/jrebel-stable-nosetup.zip && \
unzip -q "${HOME_DIR}/jrebel.zip" -d "${HOME_DIR}"

# Copy files for the application
COPY --chown=glassfish:glassfish --from=builder /target/dataverse-*.war ${HOME_DIR}/dvinstall/dataverse.war
COPY --chown=glassfish:glassfish dataverse/scripts/api/data ${HOME_DIR}/dvinstall/data
COPY --chown=glassfish:glassfish dataverse/scripts/api/*.sh ${HOME_DIR}/dvinstall/
COPY --chown=glassfish:glassfish dataverse/scripts/database/reference_data.sql ${HOME_DIR}/dvinstall/
COPY --chown=glassfish:glassfish dataverse/conf/jhove/* ${HOME_DIR}/dvinstall/

# Copy across docker scripts
COPY --chown=glassfish:glassfish docker/dataverse-k8s/bin/* docker/dataverse-k8s/glassfish/bin/* docker/dataverse-k8s/glassfish-dev/bin/* ${SCRIPT_DIR}/
RUN mkdir -p ${SCRIPT_DIR}/init.d && \
chmod +x ${SCRIPT_DIR}/*
52 changes: 52 additions & 0 deletions docker/dataverse-k8s/glassfish-dev/bin/init_0_enabledev.sh
@@ -0,0 +1,52 @@
#!/bin/bash

set -e

###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ######
# This script enables different development options, like a JMX connector
# usable with VisualVM, JRebel hot-reload support and JDWP debugger service.
# Enable it by adding env vars on startup (e.g. via ConfigMap)
###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ######

# 0. Init variables
ENABLE_JMX=${ENABLE_JMX:-0}
ENABLE_JDWP=${ENABLE_JDWP:-0}
ENABLE_JREBEL=${ENABLE_JREBEL:-0}
JDWP_PORT=${JDWP_PORT:-9009}

# 1. if any options need to be set, start the server...
if [ "x${ENABLE_JMX}" = "x1" ] || [ "x${ENABLE_JMX}" = "x1" ] || [ "x${ENABLE_JREBEL}" = "x1" ]; then
echo "Starting application server..."
asadmin start-domain
fi

# 2. Enable JMX (metrics + performance)
if [ "x${ENABLE_JMX}" = "x1" ]; then
echo "Enabling JMX Remote on port 4000/4001. Remember you need to connect to localhost, e.g. via port-forwarding."
asadmin create-jvm-options "\-Dcom.sun.management.jmxremote"
asadmin create-jvm-options "\-Dcom.sun.management.jmxremote.port=4000"
asadmin create-jvm-options "\-Dcom.sun.management.jmxremote.rmi.port=4001"
asadmin create-jvm-options "\-Dcom.sun.management.jmxremote.ssl=false"
asadmin create-jvm-options "\-Dcom.sun.management.jmxremote.authenticate=false"
asadmin create-jvm-options "\-Djava.rmi.server.hostname=127.0.0.1"
fi

# 3. Enable JDWP (debugger)
if [ "x${ENABLE_JDWP}" = "x1" ]; then
echo "Enabling JDWP debugger, listening on port ${JDWP_PORT} of this container/pod."
asadmin create-jvm-options "\-agentlib\:jdwp=transport=dt_socket,server=y,suspend=n,address=${JDWP_PORT}"
fi

# 4. Enable JRebel (hot-redeploy)
if [ "x${ENABLE_JREBEL}" = "x1" ] && [ -s "${JREBEL_LIB}" ]; then
echo "Enabling JRebel support with enabled remoting_plugin option."
asadmin create-jvm-options "\-agentpath\:${JREBEL_LIB}"
asadmin create-jvm-options "\-Drebel.remoting_plugin=true"
fi

# 5. Stop the server
# 1. if any options need to be set, start the server...
if [ "x${ENABLE_JMX}" = "x1" ] || [ "x${ENABLE_JMX}" = "x1" ] || [ "x${ENABLE_JREBEL}" = "x1" ]; then
echo "Stopping application server..."
asadmin stop-domain
fi

0 comments on commit 10e5f3b

Please sign in to comment.