docker/mod/mongo/init-replica.sh
chandi 61676a042d enable mongodb oplog
necessary for query.observerChanges to work probably with changes to mongodb via a different client.
Otherwise some events are missing due to a fallback via polling, which leads to lost state updates in the meantime.

took me now 3 days to debug....  :'D
2021-02-24 21:45:25 +01:00

16 lines
308 B
Bash
Executable File

#!/bin/sh
set -e
host=${HOSTNAME:-$(hostname -f)}
# init replset with defaults
mongo local --eval "rs.initiate({
_id: 'rs0',
members: [ { _id: 0, host: '127.0.0.1:27017' } ]
})"
echo "Waiting to become a master"
echo 'while (!db.isMaster().ismaster) { sleep(100); }' | mongo
echo "I'm the master!"