Skip to content

Instantly share code, notes, and snippets.

@4sskick
Created June 20, 2020 19:00
Show Gist options
  • Save 4sskick/d600f7988e1ca64b01cb055de750b199 to your computer and use it in GitHub Desktop.
Save 4sskick/d600f7988e1ca64b01cb055de750b199 to your computer and use it in GitHub Desktop.
#!/bin/bash
mongo --eval "db.stats()" # do a simple harmless command of some sort
RESULT=$? # returns 0 if mongo eval succeeds
if [ $RESULT -ne 0 ]; then
echo "MongoDB service is not running, try to run with admin"
sleep 3 #3 secs
exit 1
else
echo "MongoDB service is running!"
sleep 3 #3 secs
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment