Quiet the output of wait-for-it (#5775)

When wait-for-it is trying to connect and failing, bash emits errors on
stderr. This captures those errors and sends them to /dev/null.

This also replaces an internal wait_tcp_port function inside
entrypoint.sh with a call to wait-for-it.sh.
This commit is contained in:
Jacob Hoffman-Andrews 2021-11-05 11:38:20 -07:00 committed by GitHub
parent 44d9d50a92
commit 3d0a818bef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 23 deletions

View File

@ -10,29 +10,9 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
rm -f /var/run/rsyslogd.pid
service rsyslog start
wait_tcp_port() {
local host="$1" port="$2"
# see http://tldp.org/LDP/abs/html/devref1.html for description of this syntax.
local max_tries="120"
for n in `seq 1 $max_tries` ; do
if exec 6<>/dev/tcp/$host/$port; then
break
else
echo "$(date) - still trying to connect to $host:$port"
sleep 1
fi
if [ "$n" -eq "$max_tries" ]; then
echo "unable to connect"
exit 1
fi
done
exec 6>&-
echo "Connected to $host:$port"
}
# make sure we can reach the mysqldb and Redis cluster is done being created.
wait_tcp_port boulder-mysql 3306
wait_tcp_port 10.33.33.10 4218
./test/wait-for-it.sh boulder-mysql 3306
./test/wait-for-it.sh 10.33.33.10 4218
# create the database
MYSQL_CONTAINER=1 $DIR/create_db.sh

View File

@ -8,7 +8,7 @@ wait_tcp_port() {
# see http://tldp.org/LDP/abs/html/devref1.html for description of this syntax.
local max_tries="40"
for n in `seq 1 "${max_tries}"` ; do
if exec 6<>/dev/tcp/"${host}"/"${port}"; then
if { exec 6<>/dev/tcp/"${host}"/"${port}" ; } 2>/dev/null ; then
break
else
echo "$(date) - still trying to connect to ${host}:${port}"