entrypoint.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #!/bin/sh
  2. set -e
  3. # memory
  4. export JAVA_OPTS="${JAVA_OPTS} -Xms${JAVA_XMS:-256M} -XX:MaxRAMPercentage=${JAVA_MAXRAMPERC:-70.0}"
  5. # Jmxremote
  6. if [ "${JAVA_JMXREMOTE}" = "true" ]; then
  7. export JAVA_OPTS="${JAVA_OPTS} -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=1099"
  8. echo "[$(date -R)] [ENTRYPOINT] Enable jmxremote"
  9. fi
  10. # terminate handler
  11. sigterm_handler() {
  12. PID=$(pidof java)
  13. echo "[$(date -R)] [ENTRYPOINT] Received shutdown signal at $(date), forwarding to PID: ${PID}"
  14. if [ "${PID}" -ne 0 ]; then
  15. kill "${PID}"
  16. fi
  17. }
  18. # if we receive SIGTERM (from docker stop) or SIGINT (ctrl+c if not running as daemon)
  19. # trap the signal and delegate to sigterm_handler function, which will notify hazelcast instance process
  20. trap sigterm_handler TERM INT
  21. # shellcheck disable=SC2086
  22. java ${JAVA_OPTS} -jar /service/spsassembler.jar server "${CONFIGFILE}" &
  23. PID="$!"
  24. echo "[$(date -R)] [ENTRYPOINT] Starting service with process id: ${PID}"
  25. echo ""
  26. # wait on hazelcast instance process
  27. wait "${PID}"
  28. # if a signal came up, remove previous traps on signals and wait again (noop if process stopped already)
  29. trap - TERM INT
  30. wait "${PID}"