@@ -21,9 +21,11 @@ export REGISTRY_PORT="${PORT:-5000}"
2121
2222export BUCKET_NAME=" ${BUCKET_NAME:- registry} "
2323
24+ echo " registry: environment ETCD=${ETCD} ETCD_PATH=${ETCD_PATH} HOST_ETCD_PATH=${HOST_ETCD_PATH} ETCD_TTL=${ETCD_TTL} REGISTRY_PORT=${REGISTRY_PORT} EXTERNAL_PORT=${EXTERNAL_PORT} BUCKET_NAME=${BUCKET_NAME} "
25+
2426# wait for etcd to be available
2527until etcdctl --no-sync -C " $ETCD " ls > /dev/null 2>&1 ; do
26- echo " registry: waiting for etcd at $ETCD ..."
28+ echo " registry: waiting for etcd at ${ ETCD} ..."
2729 sleep $(( ETCD_TTL/ 2 )) # sleep for half the TTL
2830done
2931
@@ -35,8 +37,7 @@ function etcd_set_default {
3537 ERROR=" $( etcdctl --no-sync -C " $ETCD " mk " $ETCD_PATH /$1 " " $2 " 2>&1 > /dev/null) "
3638
3739 if [[ $? -ne 0 ]] && echo " $ERROR " | grep -iqve " key already exists" ; then
38- echo " registry: etcd_set_default: an etcd error occurred ($ERROR )"
39- echo " registry: aborting..."
40+ echo " registry: etcd_set_default($1 =$2 ) aborting, an etcd error occurred ($ERROR )"
4041 exit 1
4142 fi
4243 set -e
@@ -53,15 +54,20 @@ until confd -onetime -node "$ETCD" --confdir /app --log-level error; do
5354done
5455
5556# ensure registry bucket exists
57+ echo " registry: creating bucket"
5658/app/bin/create_bucket
59+ echo " registry: bucket created"
5760
5861# spawn the service in the background
62+ echo " registry: starting registry"
5963cd /docker-registry
6064sudo -E -u registry docker-registry &
6165SERVICE_PID=$!
66+ echo " registry: docker registry started in background with pid: ${SERVICE_PID} "
6267
6368# smart shutdown on SIGINT and SIGTERM
6469function on_exit() {
70+ echo " registry: on_exit() called"
6571 kill -TERM $SERVICE_PID
6672 wait $SERVICE_PID 2> /dev/null
6773 exit 0
@@ -71,8 +77,6 @@ trap on_exit INT TERM
7177# spawn confd in the background to update services based on etcd changes
7278confd -node " $ETCD " --confdir /app --log-level error --interval 5 &
7379
74- echo " deis-registry running..."
75-
7680# publish the service to etcd using the injected EXTERNAL_PORT
7781if [[ ! -z $EXTERNAL_PORT ]]; then
7882
@@ -83,8 +87,9 @@ if [[ ! -z $EXTERNAL_PORT ]]; then
8387 set +e
8488
8589 # wait for the service to become available on PORT
86- sleep 1 && while [[ -z $( netstat -lnt | awk " \$ 6 == \" LISTEN\" && \$ 4 ~ \" .$PORT \" && \$ 1 ~ \" $PROTO .?\" " ) ]] ; do sleep 1; done
90+ sleep 1 && while [[ -z $( netstat -lnt | awk " \$ 6 == \" LISTEN\" && \$ 4 ~ \" .$PORT \" && \$ 1 ~ \" $PROTO .?\" " ) ]] ; do sleep 1; echo " registry: waiting for service to become available " ; done
8791
92+ echo " registry: starting loop to update service discovery"
8893 # while the port is listening, publish to etcd
8994 while [[ ! -z $( netstat -lnt | awk " \$ 6 == \" LISTEN\" && \$ 4 ~ \" .$PORT \" && \$ 1 ~ \" $PROTO .?\" " ) ]] ; do
9095 if etcdctl --no-sync -C " $ETCD " mk " ${ETCD_PATH} /masterLock" " $HOSTNAME " --ttl " $ETCD_TTL " > /dev/null 2>&1 \
0 commit comments