Docker Catch Sigterm1
Sometimes I like to stash commands that I use regularly. Below is a snippet of code that I find helpful from time to time. Here is a good script for catching sigterms inside of a docker container.
#!/bin/bash
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
Comments
Leave a comment
Terrific article! That is the kind of information that aree supposed to be shared around tthe web. Shame oon Google for now not positioning thjis post upper! Come on over annd discuss wigh my sitye . Thank you =) xnxx