Prior to running rootxamine, SpecTcl must be started and must run both its mirror server and REST server. Both of these are used to map to the shared memory. If SpecTcl is run remotely, a mirror of the shared memory is transparently set up.
How you do this depends on the environment in which SpecTcl is running. In the analysis environment where the NSCLDAQ servers are not running, you must specify a unique integer port. This port must be unique system wide.
Here's an example of a chunk of SpecTclInit.tcl that does this. Note these lines must be placed in SpecTclInit.tcl, not SpecTclRC.tcl:
This sets the value of the REST port (HTTPDPort
)
to 8080 and the Mirror server port
(MirrorPort
) to 8081. Note again,
these are sample values and each SpecTcl instance in the system
that uses a REST server and a Mirror server must use unique port
vales for both.
The NSCLDAQ servers include a port manager service. This service manages a pool of TCP/IP ports. On request from a client it can allocate a port and associate a name and user with that port. This allows you to ensure your REST and Mirror server ports are unique and can be looked up by name (and optionally the name of the user running SpecTcl in an experiment).
Here's an example fragment from SpecTclInit.tcl that shows how to use the port manager to allocate a unique set of ports and to assign meaningful names to them.
Example 2-2. Setting the HTTPD and Mirror ports using the port manager
lappend auto_path [file join $SpecTclHome TclLibs]if {[array names env DAQTCLLIBS] ne ""} { lappend auto_path $env(DAQTCLLIBS)
} package require DAQService
set HTTPDPort [SpecTcl::getServicePort SpecTcl_REST]
set MirrorPort [SpecTcl::getServicePort SpecTcl_MIRROR]
If that variable is defined, we append it to the package load path. If you have not set up the a version of NSCLDAQ 12 or later, or not set up NSCLDAQ at all, this environment variable will not be defined and you'll need to set the TCLLIBPATH environment variable to include $DAQROOT/TclLibs. TCLLIBPATH is a space separated set of directory tree tops that will also be searched for packages.
If you don't add NSCLDAQ Tcl libraries to the search path, this SpecTclInit.tcl will fail to run properly.
Note that service names are qualified by the username of the user running the program that allocated the port. This means that, unlike using literal port numbers, which must be unique system wide, your service names only need to be unique within all SpecTcl's you run on that system.