drms_server

Synopsis: drms_server [-f] [-L] [-h] [-v] [-s] [-n]

Usage:    drms_server [-h]
          drms_server [-Vsnf]
Options:  -h: Print this help message.
          -V: Verbose debug output.
          -A: Archive SUs opened for writing during this session.
          -L: Redirect stdout and stderr to SU log files.
          -f: Run server in the foreground.
          -s: Commit after every module exit and continue after
          errors.
          -n: Turn off Nagle's algorithm on TCP/IP sockets. 
Additional parameters:
     params for database connection, if these are NULL drms_server gets the values from ~/.pgpass
          JSOC_DBHOST(NULL)
          JSOC_DBNAME(NULL)
          JSOC_DBUSER(NULL)
          JSOC_DBPASSWD(NULL)
     params for default overrides
          DRMS_RETENTION(-1) Retention in days. If not -1 then this value overrides
                       the retention time for storage units created by this 
                       session. Server only.
          DRMS_QUERY_MEM(512) Maximum amount of memory (in MB) used by a single record query.
                       Note this is for the record information, not segment size.
          DRMS_SERVER_WAIT(1) Non-zero value indicates waiting 2 seconds before exiting, otherwise don't wait.
From environment:
          USER

drms_server starts the DRMS server program for a user's session. Each session has its own instance of the drms_server program running. drms_server is usually run from withing the drms_run (see DrmsRunCmd) script but can also be run in a script created by a user when multiple pipeline modules will be run inside a single session.

The "-f" flag makes the server run in the foreground. Without "-f" the drms_server command spawn a server in a background process, prints the connection info to stdout and exits.

The "-L" flag turns off saving the server stdout and stderr in SUMS and cataloged in the session table.

The following notes may need to be updated:

Running one or more DRMS modules involves three main steps 

a) starting a DRMS session, 
b) runnning the module(s) and 
c) closing the session.

The final step will either commit all the data generated by 
modules in the session or discard it if an error occured.

The script /jsoc/scripts/drms/drms_run automates the three steps
detailed below, and allows modules (or scripts containing multiple 
module commands) to be run with a single command.
The command

  host:~> drms_run <command> [options...]

will start a new DRMS server, run <command> and depending on the exit
status of <command> will either commit or discard changes to the
database and stop the DRMS server. drms_run will use the drms_server
executable pointed to by the environment variable DRMS_SERVER_EXE. If
DRMS_SERVER_EXE is not set drms_run will assume that an executable
"drms_server" is in your path. The output from the DRMS server is
piped to the file pointed to by the environment variable
DRMS_LOGFILE. If DRMS_SERVER_EXE is not set drms_run will create a log
file in /tmp/DRMS.<pid>, where pid is the PID of the drms_run
script interpreter.

The three steps are carried out as follows: 

  a) Before you run modules you must have a DRMS server running to 
     act as a session master. This can be done by running the command

     host:~>  jsoc/bin/<target>/drms_server -f

     The server will print out what interface it is listening
     for connections on. For example:

      akhenaten:~/jsoc> bin/custom.akhenaten/drms_server -f
      DRMS_HOST = akhenaten.Stanford.EDU
      DRMS_PORT = 33137
      DRMS_PID = 20955
      DRMS_SESSIONID = 946
      DRMS_SUNUM = 28201
      DRMS_SUDIR = /SUM5/D28201
      DRMS server started with pid=20955, noshare=0, noroe=0
      ...

     The "-f" flag makes the server run in the foreground. Without
     "-f" the drms_server command spawn a server in a background 
     process, prints the connection info to stdout (as above) 
     and exits. 

     The server will print log messages to stdout and
     stderr. These will be copied (tee'ed) into files named drms_server.stdout and drms_server.stderr
     in the DRMS_SUDIR directory unless the "-L" nolog flag is given to drms_server.
     should be piped to a file if you intend to keep them. DRMS_SUDIR is provided by SUMS
     with the SUMS index DRMS_SUNUM.  The SUMS directory is kept in the drms_session table for
     the current namespace in which drms_server is run during the session or when drms_server aborts. 
     If drms_server commits, the SUMS directory is set to NULL in the drms_session table. 
     The retention time is set to the max of retention times of records saved in the same session 
     unless overridden with the "DRMS_RETENTION" parameter to drms_server.  
     The logs are kept in DRMS_LOG_TAPEGROUP.

    
  b) Now you can run the module(s). The modules do not need to run on
     the same host as the server. They can run on any host as long as
     they are able to open a TCP socket connection to the server
     process.

     When running a module, the named parameter DRMSSESSION must be set 
     to indicate the host and port where the DRMS server is listening 
     for connection attempts. It is perhaps most convenient to do this 
     by setting the environment variable DRMSSESSION. In the example above 
     this would mean executing the command: 
   
     akhenaten:~/jsoc> setenv DRMSSESSION akhenaten:33137

     Each module that connects causes the server to spawn a new thread
     to service the new client.  The server can service multiple
     clients simultaneously, but database operations are serialized
     within the server and executed sequentially using a shared
     connection to the DRMS database.


  3. When all modules have finished successfully you can either
     
       a) tell the DRMS server stop and commit all data generated or 
          modified by the modules to the DRMS database by sending a 
          SIGUSR1 signal to it. In the example above that would mean 
          issuing the command

          akhenaten:~/jsoc> kill -s USR1 20955
     
     or if an error occurs you can
  
      b) tell the DRMS server to abort and discard all data generated
         by the modules by sending it a SIGTERM, SIGQUIT or SIGINT.
         In the example above that could be done by pressing CTRL-C
         in the terminal where the server is running or by issuing
         the command 

         akhenaten:~/jsoc> kill -s INT 20955    
     
         It should be safe to kill the server with SIGKILL (kill -9).
         It will have the same effect as a regular abort except that it 
         leaves a stale entry in DRMS's active session table.

JsocWiki: DrmsServerCmd (last edited 2013-05-01 04:35:25 by localhost)