Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Commit

Permalink
Merge d857735 into a1ce3cd
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Fisher committed Apr 17, 2014
2 parents a1ce3cd + d857735 commit 3a9f960
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions logger/bin/boot
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ SERVICE_PID=$!

# smart shutdown on SIGINT and SIGTERM
function on_exit() {
kill -TERM $SERVICE_PID
wait $SERVICE_PID 2>/dev/null
kill -TERM $SERVICE_PID
wait $SERVICE_PID 2>/dev/null
}
trap on_exit INT TERM

Expand All @@ -34,24 +34,24 @@ echo deis-logger running...
# publish the service to etcd using the injected PORT
if [[ ! -z $PUBLISH ]]; then

# configure service discovery
PORT=${PORT:-514}
PROTO=${PROTO:-tcp}
# configure service discovery
PORT=${PORT:-514}
PROTO=${PROTO:-udp}

set +e
set +e

# wait for the service to become available on PUBLISH port
sleep 1 && while [[ -z $(netstat -lnt | awk "\$6 == \"LISTEN\" && \$4 ~ \".$PUBLISH\" && \$1 ~ \"$PROTO.?\"") ]] ; do sleep 1; done
# wait for the service to become available on PUBLISH port
sleep 1 && while [[ -z $(netstat -lnu | awk "\$4 ~ \".$PUBLISH\" && \$1 ~ \"$PROTO.?\"") ]] ; do sleep 1; done

# while the port is listening, publish to etcd
while [[ ! -z $(netstat -lnt | awk "\$6 == \"LISTEN\" && \$4 ~ \".$PUBLISH\" && \$1 ~ \"$PROTO.?\"") ]] ; do
etcdctl --no-sync -C $ETCD set $ETCD_PATH/host $HOST --ttl $ETCD_TTL >/dev/null
etcdctl --no-sync -C $ETCD set $ETCD_PATH/port $PORT --ttl $ETCD_TTL >/dev/null
sleep $(($ETCD_TTL/2)) # sleep for half the TTL
done
# while the port is listening, publish to etcd
while [[ ! -z $(netstat -lnu | awk "\$4 ~ \".$PUBLISH\" && \$1 ~ \"$PROTO.?\"") ]] ; do
etcdctl -C $ETCD set --ttl $ETCD_TTL $ETCD_PATH/host $HOST --no-sync >/dev/null
etcdctl -C $ETCD set --ttl $ETCD_TTL $ETCD_PATH/port $PORT --no-sync >/dev/null
sleep $(($ETCD_TTL/2)) # sleep for half the TTL
done

# if the loop quits, something went wrong
exit 1
# if the loop quits, something went wrong
exit 1

fi

Expand Down

0 comments on commit 3a9f960

Please sign in to comment.