Skip to content

Commit b08c9fc

Browse files
committed
[OPENJDK-2968] move ARGS/OPTS handling to run-java.sh
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]>
1 parent cb9429b commit b08c9fc

File tree

2 files changed

+26
-14
lines changed
  • modules
    • run/artifacts/opt/jboss/container/java/run
    • s2i/bash/artifacts/usr/local/s2i

2 files changed

+26
-14
lines changed

modules/run/artifacts/opt/jboss/container/java/run/run-java.sh

+20-1
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,16 @@ function configure_passwd() {
227227
fi
228228
}
229229

230+
handle_java_options() {
231+
# JAVA_OPTIONS is a deprecated name for JAVA_OPTS. It is not supported
232+
# in the images from UBI9 onwards.
233+
if [ -z "${JAVA_OPTS+isunset}" ] && [ -n "${JAVA_OPTIONS+isset}" ]; then
234+
JAVA_OPTS="$JAVA_OPTIONS"
235+
fi
236+
export JAVA_OPTS
237+
export JAVA_OPTIONS="$JAVA_OPTS"
238+
}
239+
230240
# Start JVM
231241
startup() {
232242
# Initialize environment
@@ -251,4 +261,13 @@ startup() {
251261

252262
# =============================================================================
253263
# Fire up
254-
startup $*
264+
265+
handle_java_options
266+
267+
if [ -f "${S2I_TARGET_DEPLOYMENTS_DIR}/bin/run.sh" ]; then
268+
echo "Starting the application using the bundled ${S2I_TARGET_DEPLOYMENTS_DIR}/bin/run.sh ..."
269+
exec ${DEPLOYMENTS_DIR}/bin/run.sh $* ${JAVA_ARGS}
270+
else
271+
echo "Starting the Java application using ${JBOSS_CONTAINER_JAVA_RUN_MODULE}/run-java.sh $*..."
272+
startup $* ${JAVA_ARGS}
273+
fi

modules/s2i/bash/artifacts/usr/local/s2i/run

+6-13
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ source "${JBOSS_CONTAINER_JAVA_S2I_MODULE}/s2i-core-hooks"
1111
# Global S2I variable setup
1212
s2i_core_env_init
1313

14-
if [ -z "${JAVA_OPTS+isunset}" ] && [ -n "${JAVA_OPTIONS+isset}" ]; then
15-
JAVA_OPTS="$JAVA_OPTIONS"
16-
fi
17-
1814
if [ -f "${JBOSS_CONTAINER_JOLOKIA_MODULE}/jolokia-opts" ]; then
1915
# Always include jolokia-opts, which can be empty if switched off via env
2016
S2I_RUN_OPTS="${S2I_RUN_OPTS} $(${JBOSS_CONTAINER_JOLOKIA_MODULE}/jolokia-opts)"
@@ -24,13 +20,10 @@ if [ -f "${JBOSS_CONTAINER_PROMETHEUS_MODULE}/prometheus-opts" ]; then
2420
fi
2521

2622
export S2I_RUN_OPTS
27-
export JAVA_OPTS
28-
export JAVA_OPTIONS="$JAVA_OPTS"
2923

30-
if [ -f "${S2I_TARGET_DEPLOYMENTS_DIR}/bin/run.sh" ]; then
31-
echo "Starting the application using the bundled ${S2I_TARGET_DEPLOYMENTS_DIR}/bin/run.sh ..."
32-
exec ${DEPLOYMENTS_DIR}/bin/run.sh $args ${JAVA_ARGS}
33-
else
34-
echo "Starting the Java application using ${JBOSS_CONTAINER_JAVA_RUN_MODULE}/run-java.sh $args..."
35-
exec "${JBOSS_CONTAINER_JAVA_RUN_MODULE}/run-java.sh" $args ${JAVA_ARGS}
36-
fi
24+
# XXX this is needed to support a user-provided alternative run script but we
25+
# should probably export all relevant S2I variables, possibly by moving the
26+
# above `source` statements into run-java.sh
27+
export S2I_TARGET_DEPLOYMENTS_DIR
28+
29+
exec "${JBOSS_CONTAINER_JAVA_RUN_MODULE}/run-java.sh" $args

0 commit comments

Comments
 (0)