[SERVER-25840] Ability for runProgram() to specify environment Created: 29/Aug/16  Updated: 06/Dec/22  Resolved: 03/Dec/21

Status: Closed
Project: Core Server
Component/s: Shell, Testing Infrastructure
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Minor - P4
Reporter: Kevin Pulo Assignee: Backlog - Server Tooling and Methods (STM) (Inactive)
Resolution: Won't Fix Votes: 1
Labels: move-stm
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-18877 Allow MongoRunner.runMongod Take In E... Closed
Assigned Teams:
Server Tooling & Methods
Participants:

 Description   

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", ... } } )



 Comments   
Comment by Brooke Miller [ 03/Dec/21 ]

We've deprecated the mongo shell in favor of the new mongosh. Unfortunately, we aren't able to pursue improvements to the deprecated shell except in extreme cases, such as critical security fixes. Please start making use of mongosh and let us know if it works for you in this case.

Comment by Kevin Pulo [ 31/Aug/16 ]

Of course I can. How did I miss this? Updating the description and lowering to P4.

Comment by Jonathan Reams [ 30/Aug/16 ]

Why can't you call "waitProgram" ? It looks like that should do what you want.

Generated at Thu Feb 08 04:10:22 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.