if (this.proxyHost != null && this.proxyHost.length() > 0) {
this.addProxySelector();
}
MongodExecutable executable;
try {
final ICommandLinePostProcessor commandLinePostProcessor;
if (authEnabled) {
commandLinePostProcessor = new ICommandLinePostProcessor() {
@Override
public List<String> process(final Distribution distribution, final List<String> args) {
args.remove("--noauth");
args.add("--auth");
return args;
}
};
} else {
commandLinePostProcessor = new ICommandLinePostProcessor.Noop();
}
IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder()
.defaults(Command.MongoD)
.processOutput(getOutputConfig())
.artifactStore(getArtifactStore())
.commandLinePostProcessor(commandLinePostProcessor)
.build();
if (randomPort) {
port = PortUtils.allocateRandomPort();
}
savePortToProjectProperties();
IMongodConfig config = new MongodConfigBuilder()
.version(getVersion()).net(new Net(bindIp, port, Network.localhostIsIPv6()))
.replication(new Storage(getDataDirectory(), null, 0))
.build();
executable = MongodStarter.getInstance(runtimeConfig).prepare(config);
} catch (UnknownHostException e) {
throw new MojoExecutionException("Unable to determine if localhost is ipv6", e);
} catch (DistributionException e) {
throw new MojoExecutionException("Failed to download MongoDB distribution: " + e.withDistribution(), e);
} catch (IOException e) {
throw new MojoExecutionException("Unable to Config MongoDB: ", e);
}
try {
MongodProcess mongod = executable.start();
if (wait) {
while (true) {
try {
TimeUnit.MINUTES.sleep(5);