joyent-portal/docker/frontend/bin/reload-nginx.sh

33 lines
695 B
Bash
Raw Normal View History

2017-07-31 23:10:04 +03:00
#!/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