mirror of
https://github.com/dolthub/dolt.git
synced 2026-04-28 20:49:43 -05:00
Merge pull request #6134 from dolthub/fulghum/kill-python
[no-release-notes] Small simplification to `wait_for_connection` function
This commit is contained in:
@@ -13,21 +13,16 @@ wait_for_connection() {
|
||||
user=${SQL_USER:-dolt}
|
||||
end_time=$((SECONDS+($timeout/1000)))
|
||||
|
||||
# BATS has 'set -e' enabled, which causes the script to fail immediately if any subcommand returns a non-zero
|
||||
# exit code, so we need to temporarily enable 'set +e', but be sure to turn 'set -e' back on before we exit.
|
||||
set +e
|
||||
while [ $SECONDS -lt $end_time ]; do
|
||||
dolt sql-client -u $user --host localhost --port $port --use-db "$DEFAULT_DB" --timeout 1 -q "SELECT 1;"
|
||||
if [ $? -eq 0 ]; then
|
||||
run dolt sql-client -u $user --host localhost --port $port --use-db "$DEFAULT_DB" --timeout 1 -q "SELECT 1;"
|
||||
if [ $status -eq 0 ]; then
|
||||
echo "Connected successfully!"
|
||||
set -e
|
||||
return 0
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
echo "Failed to connect to database $DEFAULT_DB on port $port within $timeout ms."
|
||||
set -e
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user