Passing extra options to the Mongo driver
It's possible to provide extra connection settings to the Mongo driver by setting the MONGO_OPTIONS environment variable to a JSON string, e.g.:
1
# we need to pass the contents of PEMs, etc in a format compatible with JSON, so add '\n' to the end of each line.
2
export TLS_CRT=$(cat /pems/tls.crt | awk '{printf "%s\\n",$0} END {print ""}')
3
export PEM=$(cat /pems/mongo.pem | awk '{printf "%s\\n",$0} END {print ""}')
4
export KEY=$(cat /pems/mongo.key | awk '{printf "%s\\n",$0} END {print ""}')
5
# now insert all the credentials into the JSON OPTIONS string
6
export MONGO_OPTIONS='{"sslCA":["'${TLS_CRT}'"],"sslCert":"'${PEM}'","sslKey":"'${KEY}'"}'
Copied!
You might want to do this, for example, if you're backing Rocket.Chat with a TLS-secured Mongo replica set and need to pass certificates/PEM files, etc. to connect to it.
If you see the following error during startup:
1
MongoTimeoutError: Server selection timed out after 10000 ms
Copied!
You can try increasing server selection time adding the following property to MONGO_OPTIONS to change the default value of 10000 to 20000:
1
MONGO_OPTIONS='{ "serverSelectionTimeoutMS": 20000 }'
Copied!
Last modified 1yr ago
Export as PDF
Copy link