Created
March 4, 2014 00:11
-
-
Save aviddiviner/9337504 to your computer and use it in GitHub Desktop.
Quick bash wrapper around a service; allows for environment setup and sends trapped signals
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
handler () { | |
kill -s SIGINT $PID | |
while kill -0 $PID &>/dev/null | |
do | |
wait $PID | |
done | |
} | |
# setup | |
run_my_service & | |
PID=$! | |
trap handler SIGINT | |
wait $PID |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this. I used this as a basis to build this wrapper for python's celery worker
https://gist.github.com/rchrd2/9d1a5dbade6c9ce5c794