You are here

The environment

In this section we describe how to control the environment for the PROOF session. The PROOF session consists of a set of processes (master and workers); these processes take the environment of the shells from which they are started up. Therefore, to be effective, any environment change must be done before the process startup.

In the case of PROOF-Lite, the workers inherit the environment of the client session. However, the functionality described in this session applies also for PROOF-Lite.

  1. The TProof interface
  2. The proofserv wrapper script
    1. The PROOF_INITCMD variable
    2. The PROOF_WRAPPERCMD variable

1. The TProof interface

To control the environment, the interface class TProof owns a static list of environment variables to be forwarded to the daemons before starting the session processes. The internal list is controlled by a few static methods:

  • AddEnvVar: add an environment variable to the list
    void TProof::AddEnvVar(const char *name, const char *value)
    
    This method adds an environment variable called 'name' with value 'value' to the internal list.
  • DelEnvVar: remove form the list an environment variable
    void TProof::DelEnvVar(const char *name)
    
    This method removes form the internal list the first occurrence of an environment variable called 'name'. 
  • GetEnvVars: get the list of environment variables
    const TList *TProof::GetEnvVars()
    
    This method returns a pointer to the internal list of environment variables. 
  • ResetEnvVars: clear the list of environment variables
    void TProof::ResetEnvVars()
    
    This method clears the list of environment variables. 

The name and values of the specified environment variables can contain the place-holders and which are substituted with the username and the ROOTSYS path, respectively.

Since ROOT 5.27/06 (SVN revision 34718) it is possible to define - via the special variable PROOF_ENVVARS - a list of environment variables to be transmitted to nodes. This allows to change the settings without changing the application or the macro running TProof::Open . For example:

$ export MYENV1=myenviron1 ; export MYENV2=myenviron2 ; export MYENV3=myenviron3
$ export PROOF_ENVVARS="MYENV1,MYENV2,MYENV3"
$ root -l
root [0] TProof *p = TProof::Open("")
Info in <:init>: the following env variables have added to the list: 'MYENV1,MYENV2,MYENV3'
Starting master: opening connection ...
...
PROOF notifies the variables added. A variable must be defined in the shell where ROOT is run; otherwise it is not added (a warning is issued).

The variables defined via PROOF_ENVVARS are added to the internal list when constructing the TProof instance; they can be removed from the list with TProof::DelEnvVar at any moment prior to the call to TProof::Open. 

2. The proofserv wrapper script

The PROOF sessions on the server side (master and workers) are instances of the TProofServ class instantiated via the $ROOTSYS/bin/proofserv.exe application. The application is not launched directly but via the wrapper script $ROOTSYS/bin/proofserv . The wrapper script contains basically two parts. The first were an initialization command can be executed to setup the environment; this is controlled by the variable PROOF_INITCMD. The second in which the proofserv.exe is launched, possibly via another wrapper application; this is controlled by the PROOF_WRAPPERCMD variable.

2.1 The PROOF_INITCMD

The PROOF_INITCMD variable defines a procedure which outputs a command to be executed before starting 'proofserv.exe'. This can be a simple 'echo' command or a complicated script.
So, for example, the following are equivalent:

root [] TProof::AddEnvVar("MYVAR", "all")
is equivalent to
root [] TProof::AddEnvVar("PROOF_INITCMD", "echo export MYVAR=all")

If the setup is defined by a script, e.g. /some/path/setup-env.sh, then the script should be displayed, e.g. with 'cat':

root [] TProof::AddEnvVar("PROOF_INITCMD","cat /some/path/setup-env.sh")

If the script outputs the command to be executed, e.g. /some/path/getscram.sh, then just put the script path:

root [] TProof::AddEnvVar("PROOF_INITCMD","/some/path/getscram.sh")

2.2 The PROOF_WRAPPERCMD 

The variable PROOF_WRAPPERCMD describes an application or a script to be used to launch proofserv.exe . The natural example is valgrind (PROOF valgrinding is implemented using this technique).