Skip to content

Commit

Permalink
[OPENJDK-2968] move ARGS/OPTS handling to run-java.sh
Browse files Browse the repository at this point in the history
Move the handling of JAVA_OPTIONS, JAVA_OPTS and suffixing of
JAVA_ARGS onto the command line, as well as dispatching to an
application-supplied run script, from s2i/run to run-java.sh.

This is to make this logic available to the runtime images.

<https://issues.redhat.com/browse/OPENJDK-2968>

Signed-off-by: Jonathan Dowland <[email protected]>
  • Loading branch information
jmtd committed May 10, 2024
1 parent cb9429b commit 5d17ddd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
21 changes: 20 additions & 1 deletion modules/run/artifacts/opt/jboss/container/java/run/run-java.sh
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,16 @@ function configure_passwd() {
fi
}

handle_java_options() {
# JAVA_OPTIONS is a deprecated name for JAVA_OPTS. It is not supported
# in the images from UBI9 onwards.
if [ -z "${JAVA_OPTS+isunset}" ] && [ -n "${JAVA_OPTIONS+isset}" ]; then
JAVA_OPTS="$JAVA_OPTIONS"
fi
export JAVA_OPTS
export JAVA_OPTIONS="$JAVA_OPTS"
}

# Start JVM
startup() {
# Initialize environment
Expand All @@ -251,4 +261,13 @@ startup() {

# =============================================================================
# Fire up
startup $*

handle_java_options

if [ -f "${S2I_TARGET_DEPLOYMENTS_DIR}/bin/run.sh" ]; then
echo "Starting the application using the bundled ${S2I_TARGET_DEPLOYMENTS_DIR}/bin/run.sh ..."
exec ${DEPLOYMENTS_DIR}/bin/run.sh $* ${JAVA_ARGS}
else
echo "Starting the Java application using ${JBOSS_CONTAINER_JAVA_RUN_MODULE}/run-java.sh $*..."
startup $* ${JAVA_ARGS}
fi
14 changes: 1 addition & 13 deletions modules/s2i/bash/artifacts/usr/local/s2i/run
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ source "${JBOSS_CONTAINER_JAVA_S2I_MODULE}/s2i-core-hooks"
# Global S2I variable setup
s2i_core_env_init

if [ -z "${JAVA_OPTS+isunset}" ] && [ -n "${JAVA_OPTIONS+isset}" ]; then
JAVA_OPTS="$JAVA_OPTIONS"
fi

if [ -f "${JBOSS_CONTAINER_JOLOKIA_MODULE}/jolokia-opts" ]; then
# Always include jolokia-opts, which can be empty if switched off via env
S2I_RUN_OPTS="${S2I_RUN_OPTS} $(${JBOSS_CONTAINER_JOLOKIA_MODULE}/jolokia-opts)"
Expand All @@ -24,13 +20,5 @@ if [ -f "${JBOSS_CONTAINER_PROMETHEUS_MODULE}/prometheus-opts" ]; then
fi

export S2I_RUN_OPTS
export JAVA_OPTS
export JAVA_OPTIONS="$JAVA_OPTS"

if [ -f "${S2I_TARGET_DEPLOYMENTS_DIR}/bin/run.sh" ]; then
echo "Starting the application using the bundled ${S2I_TARGET_DEPLOYMENTS_DIR}/bin/run.sh ..."
exec ${DEPLOYMENTS_DIR}/bin/run.sh $args ${JAVA_ARGS}
else
echo "Starting the Java application using ${JBOSS_CONTAINER_JAVA_RUN_MODULE}/run-java.sh $args..."
exec "${JBOSS_CONTAINER_JAVA_RUN_MODULE}/run-java.sh" $args ${JAVA_ARGS}
fi
exec "${JBOSS_CONTAINER_JAVA_RUN_MODULE}/run-java.sh" $args ${JAVA_ARGS}

0 comments on commit 5d17ddd

Please sign in to comment.