#!/bin/sh set -e # memory export JAVA_OPTS="${JAVA_OPTS} -Xms${JAVA_XMS:-256M} -XX:MaxRAMPercentage=${JAVA_MAXRAMPERC:-70.0}" # Jmxremote if [ "${JAVA_JMXREMOTE}" = "true" ]; then export JAVA_OPTS="${JAVA_OPTS} -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=1099" echo "[$(date -R)] [ENTRYPOINT] Enable jmxremote" fi # terminate handler sigterm_handler() { PID=$(pidof java) echo "[$(date -R)] [ENTRYPOINT] Received shutdown signal at $(date), forwarding to PID: ${PID}" if [ "${PID}" -ne 0 ]; then kill "${PID}" fi } # if we receive SIGTERM (from docker stop) or SIGINT (ctrl+c if not running as daemon) # trap the signal and delegate to sigterm_handler function, which will notify hazelcast instance process trap sigterm_handler TERM INT # shellcheck disable=SC2086 java ${JAVA_OPTS} -jar /service/spsassembler.jar server "${CONFIGFILE}" & PID="$!" echo "[$(date -R)] [ENTRYPOINT] Starting service with process id: ${PID}" echo "" # wait on hazelcast instance process wait "${PID}" # if a signal came up, remove previous traps on signals and wait again (noop if process stopped already) trap - TERM INT wait "${PID}"