Skip to content

Commit

Permalink
on startup, wait for the consul agent to become available
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre Besson committed Jan 8, 2017
1 parent 463a8d1 commit 6e97b28
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions load-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function loadPropertiesFilesIntoConsul {
do
filename=$(basename $file)
app=${filename%%.*}
curl -sX PUT --data-binary @$file http://$CONSUL_URL:$CONSUL_PORT/v1/kv/config/$app/data # > /dev/null
curl --output /dev/null -sX PUT --data-binary @$file http://$CONSUL_URL:$CONSUL_PORT/v1/kv/config/$app/data
done
echo " Consul Config reloaded"
}
Expand All @@ -25,8 +25,16 @@ if [[ "$CONFIG_MODE" == "filesystem" ]]; then
automatically reloaded into Consul
Consul UI: http://$CONSUL_URL:$CONSUL_PORT/ui/#/dc1/kv/config/
----------------------------------------------------------------------"
# Load the files for the first time
loadPropertiesFilesIntoConsul

# Wait until the consul agent is up
until $(curl --output /dev/null --silent --fail http://$CONSUL_URL:$CONSUL_PORT/v1/health/state/critical); do
echo 'Trying to contact the consul agent...'
sleep 1
done

# Load the files for the first time
loadPropertiesFilesIntoConsul

# Reload the files when there is a file change
inotifywait -q -m --format '%f' -e close_write $CONFIG_DIR/ | while read
do
Expand Down

0 comments on commit 6e97b28

Please sign in to comment.