backport of commit 1b321e3e7ecf487741e722b1c9b224cbe1f3146e (#23413)

Co-authored-by: Ryan Cragun <me@ryan.ec>
This commit is contained in:
hc-github-team-secure-vault-core 2023-09-28 19:33:24 -04:00 committed by GitHub
parent b9e0d4666e
commit 15e85d26df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -12,14 +12,17 @@ set -exo pipefail
nohup nc -kl 9090 &> /dev/null < /dev/null &
# Wait for nc to be listening before we attempt to enable the socket auditor.
retries=3
attempts=3
count=0
until nc -zv 127.0.0.1 9090 &> /dev/null < /dev/null; do
wait=$((2 ** count))
count=$((count + 1))
if [ "$count" -lt "$retries" ]; then
if [ "$count" -le "$attempts" ]; then
sleep "$wait"
if ! pgrep -x nc; then
nohup nc -kl 9090 &> /dev/null < /dev/null &
fi
else
echo "Timed out waiting for nc to listen on 127.0.0.1:9090" 1>&2