Skip to content

Instantly share code, notes, and snippets.

@tghastings
Created December 6, 2017 22:47
Show Gist options
  • Save tghastings/54668646fbb6e12ee8f34f9cafe9dbde to your computer and use it in GitHub Desktop.
Save tghastings/54668646fbb6e12ee8f34f9cafe9dbde to your computer and use it in GitHub Desktop.
#!/bin/bash
# SIGTERM-handler
term_handler() {
${TOMCAT_DIR}/bin/shutdown.sh
exit 143; # 128 + 15 -- SIGTERM
}
# setup handlers
# on callback, kill the last background process, which is `tail -f /dev/null` and execute the specified handler
trap 'kill ${!}; term_handler' SIGTERM
# run application
${TOMCAT_DIR}/bin/startup.sh
ln -sf /dev/stdout ${TOMCAT_DIR}/catalina.out
# wait forever
while true
do
tail -f /dev/null & wait ${!}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment