-
Type: Improvement
-
Resolution: Won't Fix
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: Shell, Testing Infrastructure
-
Server Tooling & Methods
SERVER-18877 added the ability for _startMongoProgram() to accept an object describing the desired environment for the program being run.
However, _startMongoProgram() starts the program asynchronously, and there are times when it would be useful to set the environment for a program that is run synchronously with runProgram().
In this case it's not possible to use _startMongoProgram instead, because although it returns a pid, there is no way to wait for that pid to exit. stopMongoProcessByPid() is the close (since it takes a pid instead of a port), but it it structured such that it sends a signal (SIGTERM by default) to the process, and elevates that to SIGKILL if the process doesn't exit after a minute.
A workaround is to use waitProgram(), which is only slightly ugly:
var rc = waitProgram(_startMongoProgram( ... ));
It would be nicer if runProgram() supported the same dual calling convention as _startMongoProgram, ie:
// Normal / existing way: runProgram("program", "arg1", "arg2", ...) // With environment: runProgram( { args: [ "program", "arg1", "arg2", ... ], env: { var1: "value1", var2: "value2", ... } } )
- related to
-
SERVER-18877 Allow MongoRunner.runMongod Take In Environment Variables
- Closed