Menu

#677 Provide the ability to restart STAFProc

Future
open
5
2014-01-28
2010-12-02
Alex
No

Sometimes, we need to restart the STAFProc, but Shutdown service only can process shutdown request. Restart is necessary if the system environment variables are changed. For example, $PATH has been updated, but the process started by PROCESS service can not set the new value of $PATH to the new process, even it can't find the executable file if full path is not given.

Discussion

  • Sharon Lucas

    Sharon Lucas - 2013-07-16
    • summary: Provide restart request --> Provide the ability to restart STAFProc
    • assigned_to: Sharon Lucas
    • Group: --> Future
     
  • Sharon Lucas

    Sharon Lucas - 2014-01-28

    Another way you can restart STAFProc is by using the STAF PROCESS service to submit a command that shuts down STAF and waits for the shutdown to complete and then restarts STAFProc. For example, to restart STAFProc on a remote or local machine, run the following PROCESS START request, replacing machine with the remote machine's hostname or IP address if you want to restart STAFProc on a remote machine, or replace machine with local if you want to restart STAFProc on the local machine, You can check the {STAF/Config/StartupTime} variable on this machine before and after you submit the PROCESS START command to restart STAFProc to verify that the date/time shows that STAFProc was just restarted. For example:

    C:\>STAF machine VAR RESOLVE STRING {STAF/Config/StartupTime} 
    Response 
    -------- 
    20130701-16:46:34
    
    C:\>STAF machine PROCESS START SHELL COMMAND "STAF local SHUTDOWN SHUTDOWN {STAF/Config/Sep/Command} sleep 1m {STAF/Config/Sep/Command} STAFProc" WORKDIR {STAF/Config/STAFRoot} SAMECONSOLE STDOUT {STAF/DataDir}/STAFRestart.out STDERRTOSTDOUT WAIT 
    Error submitting request, RC: 22 
    Additional info 
    --------------- 
    STAFConnectionReadUInt: Error reading from socket: other side closed socket: 22
    

    Note that this PROCESS START command should fail with RC 22 when STAFProc is shut down on the target machine. Wait for another 30 seconds or so to give enough time to complete shutting down and restarting STAFProc on the target machine before checking the new STAFProc startup time.

    C:\>STAF machine VAR RESOLVE STRING {STAF/Config/StartupTime} 
    Response 
    -------- 
    20130701-16:48:01
    

    Notes:
    1) If machine is Windows {STAF/Config/Sep/Command} is "&" or if it is Unix, {STAF/Config/Sep/Command} is a semi-colon ";". You can specify a different name for the stdout file name if desired. It is a good idea to redirect the commands' stdout/stderr output to a file (by specifying the STDOUT and STDERRTOSTDOUT options) so that you can check it to see what went wrong if STAFProc is not restarted properly. Note that if you specify "{STAF/DataDir}/STAFRestart.out" for the STDOUT value, the {STAF/DataDir} STAF variable resolves to the data/<stafinstancename> directory in the STAF root directory on the target machine (e.g. generally C:\STAF\data\STAF on Windows or /usr/local/staf/data/STAF on Unix). So, that's the directory where the STAFRestart.out file would be written to.
    2) After submitting this PROCESS START request, you'll need to wait an additional 30 seconds or so (depending on how many services are registered in the STAF.cfg file, etc) for STAFProc to restart and then you can check the {STAF/Config/StartupTime} variable on this machine to verify that the date/time shows that STAFProc was just restarted.
    3) A more sophisticated approach would be for the command to not just sleep for 1 minute (which may be longer than it takes for STAF to actually shut down or possibly not long enough depending on the number of services registered, processes running that need to be notified, etc). Instead, you could write a script that in a loop, waits for STAFProc to shutdown by perhaps sleeping for 5 or 10 seconds and then submitting a STAF machine PING PING request and waiting for it to fail with RC 16. Then you could run this script in place of "sleep 1m" in the command. </stafinstancename>

     

Log in to post a comment.

MongoDB Logo MongoDB