I have a bash script that fails. After checking, it turns out that the failure is caused by the fact that MongoDB is accessed immediately after a restart.
For example, launch:
mongo --eval "db.version()"
gives the expected result:
MongoDB shell version: 2.4.9
connection to: test
2.4.9
during operation:
service mongodb restart; mongo --eval "db.version()"
outputs the following result: my contribution:
mongodb stop / waiting
mongodb start / running, process 1466
MongoDB shell version: 2.4.9
connection to: test
Sat Oct 25 02: 52: 29.736 Error : Could not connect to server 127.0.0.1:27017 in src / mongo / shell / mongo.js: 145
exception: connection failed
because the server is not ready yet.
bash script , MongoDB ?
service mongodb status , , .
nc -z localhost 27017 , 0, , , ( - ?)