Skip to content

Commit

Permalink
Merge pull request #89 from WadeBarnes/feature/kill-mongo-when-stop-f…
Browse files Browse the repository at this point in the history
…ails

Update the onStopServer function for Mongo
  • Loading branch information
esune authored Dec 1, 2021
2 parents f4b5194 + 152566d commit b6fd928
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions docker/backup.mongo.plugin
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,21 @@ function onStopServer(){

_authDbArg=${MONGODB_AUTHENTICATION_DATABASE:+"--authenticationDatabase ${MONGODB_AUTHENTICATION_DATABASE}"}
mongo admin ${_authDbArg} ${_portArg} -u "${_username}" -p "${_password}" --quiet --eval "db.shutdownServer()"

# Wait for server to stop ...
local startTime=${SECONDS}
printf "waiting for server to stop"
while onPingDbServer ${@}; do
printf "."
local duration=$(($SECONDS - $startTime))
if (( ${duration} >= ${DATABASE_SERVER_TIMEOUT} )); then
echoRed "\nThe server failed to stop within $(getElapsedTimeFromDuration ${duration})."
echoRed "Killing the mongod process ...\n"
pkill -INT mongod
break
fi
sleep 1
done
)
}

Expand Down

0 comments on commit b6fd928

Please sign in to comment.