Skip to content

Commit

Permalink
DO NOT MERGE: debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
sengi committed Apr 4, 2024
1 parent 43ec376 commit ecc238d
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions mongo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,26 @@ failure_hints() {
}

docker_run() {
docker run --name router-mongo -dp 27017:27017 ghcr.io/alphagov/govuk-infrastructure/mongodb:016364bbefd79123a59be4ad2ce0f338688dc16f --replSet rs0 --quiet
docker run --name router-mongo -dp 27017:27017 ghcr.io/alphagov/govuk-infrastructure/mongodb:016364bbefd79123a59be4ad2ce0f338688dc16f --replSet rs0
}

init_replicaset() {
docker exec router-mongo mongo --quiet --eval 'rs.initiate();' >/dev/null 2>&1
docker exec router-mongo mongo --eval 'rs.initiate();'
}

healthy() {
docker exec router-mongo mongo --quiet --eval \
'if (rs.status().members[0].health==1) print("healthy");' \
2>&1 | grep healthy >/dev/null
'print(rs.status();'
}

# usage: retry_or_fatal description command-to-try
retry_or_fatal() {
n=20
echo -n "Waiting up to $n s for $1"; shift
while [ "$n" -ge 0 ]; do
if "$@"; then
echo " done"
return
fi
sleep 1 && echo -n .
n=$((n-1))
done
echo "gave up"
exit 1
}

stop() {
Expand Down

0 comments on commit ecc238d

Please sign in to comment.