Skip to content

Instantly share code, notes, and snippets.

@danielperezr88
Last active November 17, 2016 17:28
Show Gist options
  • Save danielperezr88/7c30ec3d80dba88a56a8a08d024ff937 to your computer and use it in GitHub Desktop.
Save danielperezr88/7c30ec3d80dba88a56a8a08d024ff937 to your computer and use it in GitHub Desktop.
# call "rabbitmqctl stop" when exiting
trap "{ echo Stopping rabbitmq; rabbitmqctl stop; exit 0; }" TERM
echo Starting rabbitmq
rabbitmq-server &
# from docs: When Bash receives a signal for which a
# trap has been set while waiting for a command to
# complete, the trap will not be executed until the
# command completes.
#
# This is why we use & and wait here. Idea taken from:
# http://veithen.github.io/2014/11/16/sigterm-propagation.html
PID=$!
wait $PID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment