Skip to content
This repository has been archived by the owner on Jan 21, 2024. It is now read-only.

Commit

Permalink
Sleep for $DRAIN_TIME before exiting the container at shutdown.
Browse files Browse the repository at this point in the history
  • Loading branch information
diranged committed Feb 2, 2016
1 parent 625a68d commit 42aaac2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
#!/bin/bash

# Exit on *any* failure
set -e

# Default configuration variables
DOCKER_HOST_IP=$(route -n | awk '/UG[ \t]/{print $2}')
ZOOKEEPER_HOST=${ZOOKEEPER_HOST:-$DOCKER_HOST_IP}
ZOOKEEPER_PORT=${ZOOKEEPER_PORT:-2181}
VERBOSE=${VERBOSE:-}
REFRESH=${REFRESH:-30}
DRAIN_TIME=${DRAIN_TIME:-0}

# The service_hostname that we register is tricky -- it *most likely* should be
# the public hostname/ip of the docker machine itself. This is not something
Expand Down Expand Up @@ -50,3 +54,9 @@ echo "Starting zk_watcher up with the following config:"
cat /zk_watcher.cfg

zk_watcher --server ${ZOOKEEPER_HOST}:${ZOOKEEPER_PORT} --config /zk_watcher.cfg $VERBOSE_ARG

# On shutdown, optionally sleep for some arbitrary amount of time before
# exiting. This allows connections to your service registered in Zookeeper to
# drain.
echo "Sleeping ${DRAIN_TIME}s before exiting..."
sleep $DRAIN_TIME

0 comments on commit 42aaac2

Please sign in to comment.