Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-25840

Ability for runProgram() to specify environment

    XMLWordPrintable

    Details

    • Backwards Compatibility:
      Minor Change

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

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              backlog-server-stm Backlog - Server Tooling and Methods (STM)
              Reporter:
              kevin.pulo Kevin Pulo
              Participants:
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated: