Skip to content

Commit

Permalink
wait-for-it_several_databases
Browse files Browse the repository at this point in the history
  • Loading branch information
nesies authored and nesies committed Nov 16, 2023
1 parent 04e7bac commit 90e7d29
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 9 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ RUN apk add --no-cache \
COPY settings.xml download.sh camunda-run.sh camunda-tomcat.sh camunda-wildfly.sh /tmp/

RUN /tmp/download.sh
COPY camunda-lib.sh /camunda/


##### FINAL IMAGE #####
Expand Down
18 changes: 18 additions & 0 deletions camunda-lib.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
wait_for_it() {
if [ -n "${WAIT_FOR}" ]; then
found=0
for host_port in $(echo "${WAIT_FOR}" | tr ',' '\n'); do
if wait-for-it.sh "$host_port" -s -t ${WAIT_FOR_TIMEOUT} ; then
echo "$host_port available"
found=1
break
else
echo "$host_port not available"
fi
done
if [ "$found" -eq 0 ] ; then
echo "No connection available in WAIT_FOR=$WAIT_FOR"
exit 1
fi
fi
}
6 changes: 3 additions & 3 deletions camunda-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ set -Eeu

trap 'Error on line $LINENO' ERR

source $(dirname "$0")/camunda-lib.sh

# Set Password as Docker Secrets for Swarm-Mode
if [[ -z "${DB_PASSWORD:-}" && -n "${DB_PASSWORD_FILE:-}" && -f "${DB_PASSWORD_FILE:-}" ]]; then
export DB_PASSWORD="$(< "${DB_PASSWORD_FILE}")"
Expand Down Expand Up @@ -30,9 +32,7 @@ fi

CMD="/camunda/internal/run.sh start"

if [ -n "${WAIT_FOR}" ]; then
CMD="wait-for-it.sh ${WAIT_FOR} -s -t ${WAIT_FOR_TIMEOUT} -- ${CMD}"
fi
wait_for_it

# shellcheck disable=SC2086
exec ${CMD} "$@"
6 changes: 3 additions & 3 deletions camunda-tomcat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ set -Eeu

trap 'Error on line $LINENO' ERR

source $(dirname "$0")/camunda-lib.sh

# Use existing tomcat distribution if present..
CATALINA_HOME="${CATALINA_HOME:-/camunda}"

Expand Down Expand Up @@ -58,9 +60,7 @@ fi

CMD+=" run"

if [ -n "${WAIT_FOR}" ]; then
CMD="wait-for-it.sh ${WAIT_FOR} -s -t ${WAIT_FOR_TIMEOUT} -- ${CMD}"
fi
wait_for_it

# shellcheck disable=SC2086
exec ${CMD}
6 changes: 3 additions & 3 deletions camunda-wildfly.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ set -Eeu

trap 'Error on line $LINENO' ERR

source $(dirname "$0")/camunda-lib.sh

# Set default values for DB_ variables
# Set Password as Docker Secrets for Swarm-Mode
if [[ -z "${DB_PASSWORD:-}" && -n "${DB_PASSWORD_FILE:-}" && -f "${DB_PASSWORD_FILE:-}" ]]; then
Expand Down Expand Up @@ -80,9 +82,7 @@ if [ "$JMX_PROMETHEUS" = "true" ] ; then
export PREPEND_JAVA_OPTS="${PREPEND_JAVA_OPTS} -javaagent:/camunda/javaagent/jmx_prometheus_javaagent.jar=${JMX_PROMETHEUS_PORT}:${JMX_PROMETHEUS_CONF}"
fi

if [ -n "${WAIT_FOR}" ]; then
CMD="wait-for-it.sh ${WAIT_FOR} -s -t ${WAIT_FOR_TIMEOUT} -- ${CMD}"
fi
wait_for_it

# shellcheck disable=SC2086
exec ${CMD}

0 comments on commit 90e7d29

Please sign in to comment.