Skip to content

Instantly share code, notes, and snippets.

@mikedanese
Last active February 19, 2016 19:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikedanese/5b0c778a3841e9c2b3d8 to your computer and use it in GitHub Desktop.
Save mikedanese/5b0c778a3841e9c2b3d8 to your computer and use it in GitHub Desktop.
#! /bin/bash
set -o pipefail
set -o nounset
service::log() {
msg="$1"
timestamp=$(date +"[%m%d %H:%M:%S]")
printf "+++ %s: %s\n" "${timestamp}" "${msg}" > /dev/stderr
}
service::start() {
nginx -g "daemon off;"
};
service::stop() {
service::log "stopping service"
nginx -s quit;
}
trap service::stop SIGTERM;
service::log "supervisor started with pid '${$}'"
( service::start ) &
while [[ $(jobs -l | wc -l) != 0 ]]; do
wait
done
service::log "all children have exited"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment