Skip to content

Commit

Permalink
Fix rueckstiess#866: mongod version detection should respect --bina…
Browse files Browse the repository at this point in the history
…rypath
  • Loading branch information
stennie committed Oct 3, 2022
1 parent 2bdc1c2 commit 7a7cbb4
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions mtools/mlaunch/mlaunch.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,9 @@ def check_mongo_server_output(binary, argument):
stderr=subprocess.STDOUT,
stdout=subprocess.PIPE, shell=False)
except OSError as exc:
print('Failed to launch %s: %s' % (binary, exc))
raise exc
print('Failed to launch %s' % binary)
raise SystemExit(exc)


out, err = proc.communicate()
if proc.returncode:
Expand Down Expand Up @@ -193,7 +194,13 @@ def __init__(self, test=False):
# indicate if running in testing mode
self.test = test

# version of MongoDB server
# find mongod version to determine avail options for arg parser in run()
# consider --binarypath if set
for i in range(1,len(sys.argv)):
if (sys.argv[i] == "--binarypath") and (i+1 < len(sys.argv)):
self.args = dict()
self.args['binarypath'] = sys.argv[i+1]
break
self.current_version = self.getMongoDVersion()

def run(self, arguments=None):
Expand Down Expand Up @@ -927,8 +934,7 @@ def getMongoDVersion(self):
except Exception:
pass

if self.args and self.args['verbose']:
print("Detected mongod version: %s" % current_version)
print("Detected mongod version: %s" % current_version)
return current_version

def client(self, host_and_port, **kwargs):
Expand Down

0 comments on commit 7a7cbb4

Please sign in to comment.