Skip to content

Commit 792eb1e

Browse files
author
Matthew Fisher
committed
Merge pull request #766 from opdemand/fix-logger-publish-loop
fix(logger): fix publish loop
2 parents 84cdf16 + d857735 commit 792eb1e

1 file changed

Lines changed: 16 additions & 16 deletions

File tree

logger/bin/boot

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ SERVICE_PID=$!
2424

2525
# smart shutdown on SIGINT and SIGTERM
2626
function on_exit() {
27-
kill -TERM $SERVICE_PID
28-
wait $SERVICE_PID 2>/dev/null
27+
kill -TERM $SERVICE_PID
28+
wait $SERVICE_PID 2>/dev/null
2929
}
3030
trap on_exit INT TERM
3131

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

37-
# configure service discovery
38-
PORT=${PORT:-514}
39-
PROTO=${PROTO:-tcp}
37+
# configure service discovery
38+
PORT=${PORT:-514}
39+
PROTO=${PROTO:-udp}
4040

41-
set +e
41+
set +e
4242

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

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

53-
# if the loop quits, something went wrong
54-
exit 1
53+
# if the loop quits, something went wrong
54+
exit 1
5555

5656
fi
5757

0 commit comments

Comments
 (0)