Skip to content

Instantly share code, notes, and snippets.

@mikedanese
Last active Feb 19, 2016
Embed
What would you like to do?
#! /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