Merge pull request #2688 from weaveworks/issues/2684-exec-weaver

Exec weaver from weave-kube launch rather than running in background
This commit is contained in:
Adam Harrison authored and GitHub committed 2017-01-09 15:24:19 +00:00
commit 635191970f
1 file changed
+16 -19
+16 -19
View File
@@ -65,24 +65,6 @@ if [ -z "$IPALLOC_INIT" ]; then
IPALLOC_INIT="consensus=$(peer_count $KUBE_PEERS)" IPALLOC_INIT="consensus=$(peer_count $KUBE_PEERS)"
fi fi
/home/weave/weaver $EXTRA_ARGS --port=6783 $BRIDGE_OPTIONS \
--http-addr=$HTTP_ADDR --status-addr=$STATUS_ADDR --docker-api='' --no-dns \
--ipalloc-range=$IPALLOC_RANGE $NICKNAME_ARG \
--ipalloc-init $IPALLOC_INIT \
"$@" \
$KUBE_PEERS &
WEAVE_PID=$!
# Wait for weave process to become responsive
while true ; do
curl $HTTP_ADDR/status >/dev/null 2>&1 && break
if ! kill -0 $WEAVE_PID >/dev/null 2>&1 ; then
echo Weave process has died >&2
exit 1
fi
sleep 1
done
reclaim_ips() { reclaim_ips() {
ID=$1 ID=$1
shift shift
@@ -91,6 +73,13 @@ reclaim_ips() {
done done
} }
post_start_actions() {
# Wait for weave process to become responsive
while true ; do
curl $HTTP_ADDR/status >/dev/null 2>&1 && break
sleep 1
done
# Tell the newly-started weave about existing weave bridge IPs # Tell the newly-started weave about existing weave bridge IPs
/usr/bin/weaveutil container-addrs weave weave:expose | while read ID IFACE MAC IPS; do /usr/bin/weaveutil container-addrs weave weave:expose | while read ID IFACE MAC IPS; do
reclaim_ips "weave:expose" $IPS reclaim_ips "weave:expose" $IPS
@@ -116,5 +105,13 @@ export HOST_ROOT
# Expose the weave network so host processes can communicate with pods # Expose the weave network so host processes can communicate with pods
/home/weave/weave --local expose $WEAVE_EXPOSE_IP /home/weave/weave --local expose $WEAVE_EXPOSE_IP
}
wait $WEAVE_PID post_start_actions &
exec /home/weave/weaver $EXTRA_ARGS --port=6783 $BRIDGE_OPTIONS \
--http-addr=$HTTP_ADDR --status-addr=$STATUS_ADDR --docker-api='' --no-dns \
--ipalloc-range=$IPALLOC_RANGE $NICKNAME_ARG \
--ipalloc-init $IPALLOC_INIT \
"$@" \
$KUBE_PEERS