joyent-portal/docker/frontend/bin/reload-nginx.sh
2017-08-01 10:28:00 +01:00

33 lines
695 B
Bash
Executable File

#!/bin/sh
# Render Nginx configuration template using values from Consul,
# but do not reload because Nginx has't started yet
preStart() {
consul-template \
-once \
-consul localhost:8500 \
-template "/etc/nginx/nginx.conf.tmpl:/etc/nginx/nginx.conf"
}
# Render Nginx configuration template using values from Consul,
# then gracefully reload Nginx
onChange() {
consul-template \
-once \
-consul localhost:8500 \
-template "/etc/nginx/nginx.conf.tmpl:/etc/nginx/nginx.conf:nginx -s reload"
}
until
cmd=$1
if [ -z "$cmd" ]; then
onChange
fi
shift 1
$cmd "$@"
[ "$?" -ne 127 ]
do
onChange
exit
done