mirror of
https://github.com/yldio/copilot.git
synced 2024-11-15 07:40:07 +02:00
33 lines
695 B
Bash
33 lines
695 B
Bash
|
#!/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
|