how to check if mongodb is up and ready to accept connections from bash script?

后端 未结 6 1554
眼角桃花
眼角桃花 2020-12-28 20:33

I have a bash shell script which does a bunch of stuff before trying to mongorestore.

I want to make sure that not only MongoDB is up, but it is also re

6条回答
  •  醉话见心
    2020-12-28 21:01

    To test the connection in a loop like you suggest,

    until nc -z localhost 27017
    do
        sleep 1
    done
    

提交回复
热议问题