Skip to content

Instantly share code, notes, and snippets.

@gabber12
Created December 18, 2017 04:55
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save gabber12/272050d8cfd926979ef67601d9738b83 to your computer and use it in GitHub Desktop.
Save gabber12/272050d8cfd926979ef67601d9738b83 to your computer and use it in GitHub Desktop.
Shell init for docker container with signal handling
# Uncomment to print commands being executed
# set -x
pid=0
# SIGTERM-handler
term_handler() {
echo "Handler INT";
if [ $pid -ne 0 ]; then
kill -SIGTERM "$pid"
wait "$pid"
fi
exit 130;
}
# setup handlers
trap term_handler INT TERM
# Run app
java -jar server local.yml &
pid="$!"
while true
do
sleep 1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment