summaryrefslogtreecommitdiff
path: root/src/mongo/shell/servers_misc.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/shell/servers_misc.js')
-rw-r--r--src/mongo/shell/servers_misc.js20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/mongo/shell/servers_misc.js b/src/mongo/shell/servers_misc.js
index fdb49deb76a..f419428e2d0 100644
--- a/src/mongo/shell/servers_misc.js
+++ b/src/mongo/shell/servers_misc.js
@@ -214,11 +214,21 @@ function startParallelShell(jsCode, port, noConnect) {
var args = ["mongo"];
if (typeof db == "object") {
- var hostAndPort = db.getMongo().host.split(':');
- var host = hostAndPort[0];
- args.push("--host", host);
- if (!port && hostAndPort.length >= 2) {
- var port = hostAndPort[1];
+ if (!port) {
+ // If no port override specified, just passthrough connect string.
+ args.push("--host", db.getMongo().host);
+ } else {
+ // Strip port numbers from connect string.
+ const uri = new MongoURI(db.getMongo().host);
+ var connString = uri.servers
+ .map(function(server) {
+ return server.host;
+ })
+ .join(',');
+ if (uri.setName.length > 0) {
+ connString = uri.setName + '/' + connString;
+ }
+ args.push("--host", connString);
}
}
if (port) {