Skip to content
This repository was archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
sleep for 0.1s instead of 1s in the wait_for_status loop
Browse files Browse the repository at this point in the history
This reduces `weave launch|launch-dns` execution time.

Closes #992.
  • Loading branch information
rade committed Jun 23, 2015
1 parent 43b8840 commit 2d81dff
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion weave
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,18 @@ command_exists() {
command -v $1 >/dev/null 2>&1
}

fractional_sleep() {
if [ -z "$HAS_FRACTIONAL_SLEEP" ] ; then
HAS_FRACTIONAL_SLEEP=1
sleep 0.01 >/dev/null 2>&1 || HAS_FRACTIONAL_SLEEP=0
fi
if [ $HAS_FRACTIONAL_SLEEP -eq 1 ] ; then
sleep $1
else
sleep $((${1%.*} + 1))
fi
}

run_iptables() {
# -w is recent addition to iptables
if [ -z "$CHECKED_IPTABLES_W" ] ; then
Expand Down Expand Up @@ -585,7 +597,7 @@ wait_for_status() {
echo "$err_msg" >&2
return 1
fi
sleep 1
fractional_sleep 0.1
done
}

Expand Down

0 comments on commit 2d81dff

Please sign in to comment.