Skip to content
Snippets Groups Projects
Commit dc8211aa authored by Raphael Grimm's avatar Raphael Grimm
Browse files

Fix mongod.sh.in to work with new mongod versions

parent ca064728
Branches
Tags
No related merge requests found
Pipeline #
......@@ -41,19 +41,34 @@ mkdir -p "$MONGO_LOG_PATH"
startMongo ()
{
echo -e "Starting MongoDB daemon with data from ${MONGO_DATA_PATH}\n";
${MONGO_MONGOD} --fork --nojournal --dbpath "${MONGO_DATA_PATH}" --smallfiles --rest --logpath "$MONGO_LOG_PATH/mongod.log"
httpinterface="--httpinterface"
${MONGO_MONGOD} --version | grep "db version v2.4.9" && httpinterface="" #this flag does not exist on ubuntu 14.04
cmd_start="${MONGO_MONGOD} --fork --nojournal --dbpath \"${MONGO_DATA_PATH}\" --smallfiles --rest $httpinterface --logpath \"$MONGO_LOG_PATH/mongod.log\""
$cmd_start
exitcode=$?
if [ "$exitcode" -eq "100" ]; then
echo "Tried to execute:"
echo " $cmd_start"
echo "MongoDB failed start with exit code $exitcode. Trying to repair!"
${MONGO_MONGOD} --dbpath "${MONGO_DATA_PATH}" --repair
cmd_repair="${MONGO_MONGOD} --dbpath \"${MONGO_DATA_PATH}\" --repair"
$cmd_repair
exitcode=$?
if [ "$exitcode" -ne "0" ]; then
echo "Tried to execute:"
echo " $cmd_repair"
echo "Failed to repair MongoDB! Exit code was $exitcode"
exit $exitcode
else
${MONGO_MONGOD} --fork --nojournal --dbpath "${MONGO_DATA_PATH}" --smallfiles --rest --logpath "$MONGO_LOG_PATH/mongod.log"
$cmd_start
exitcode=$?
if [ "$exitcode" -ne "0" ]; then
echo "MongoDB failed start with exit code $exitcode after it was repaired. Something is wrong!"
exit $exitcode
fi
fi
elif [ "$exitcode" -ne "0" ]; then
echo "Tried to execute:"
echo " $cmd_start"
echo "MongoDB failed start with exit code $exitcode. Maybe '`basename $0` repair' will help"
exit $exitcode
else
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment