Skip to content

Instantly share code, notes, and snippets.

@aviddiviner
Created March 4, 2014 00:11
Show Gist options
  • Save aviddiviner/9337504 to your computer and use it in GitHub Desktop.
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
#!/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
@rchrd2
Copy link

rchrd2 commented Dec 6, 2014

Thanks for this. I used this as a basis to build this wrapper for python's celery worker

https://gist.github.com/rchrd2/9d1a5dbade6c9ce5c794

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment