Skip to content

Instantly share code, notes, and snippets.

@deeTEEcee
Created April 30, 2021 18:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deeTEEcee/2a9aa30f8247ee363aa111c030eeda0b to your computer and use it in GitHub Desktop.
Save deeTEEcee/2a9aa30f8247ee363aa111c030eeda0b to your computer and use it in GitHub Desktop.
mongo-connection.txt
# rs.initiate() is playing 2 roles:
# * required for my local mongo setup
# * it can also be used to test a connection but you can use almost any other evaluation command.
# The command below runs a mongo check in a loop and times out after a minute.
# Why not use "wait-for-it.sh"? That establishes a tcp connection check but you could still run into a connection error
# if you run a single mongo connection check so we still need to loop.
timeout -v 1m bash -c 'until docker exec -it mongo mongo --eval "rs.initiate()"; do sleep 3; done'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment