Last active
February 19, 2016 19:26
-
-
Save mikedanese/5b0c778a3841e9c2b3d8 to your computer and use it in GitHub Desktop.
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 | |
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