Script functions reference > Script functions in alphabetical order > T

T
Terminate
Syntax
Terminate(num_exitcode);
num_exitcode 
Values other than 0-127 are not recommended since they may have different meanings depending on the operating system.
Description
Makes the StreamServer shutdown gracefully when all jobs being processed have been completed, including the one that called the Terminate function. Once the Terminate function has been called, no new jobs will be started. You can use the exit code to inform the application that started the StreamServer why the StreamServer has been shutdown.
In UNIX bash shell scripts the exit code is stored in $? after StreamServe has exited.
Note:
If several job threads call the Terminate function at the same time the exit code is undefined. When there are several calls to the Terminate function within the same job, the last call will set the exit code.
Returns
The Terminate function always returns 1.
Examples
Example 92
To shutdown the StreamServer when all jobs have been completed:
Terminate(0);
 
Example 93
To use the exist code to leave a message to the application that started the StreamServer:
if ($encounteredWords="stop for two weeks")
    Terminate(2);
else if ($encounteredWords="stop for three weeks")
    Terminate(3);
 
Example 94
In a Windows command file you can use the %ERRORLEVEL% variable with the exit code:
strsc -a start.arg
@echo off
if %ERRORLEVEL% EQU 0 goto :END
if %ERRORLEVEL% GEQ 4 goto :END
goto return%ERRORLEVEL%
 
:return1
    echo The server stopped with an error
    goto :END
:return2
    echo The server encountered the words "stop for two weeks" in 
the data stream
    goto :END
:return3
    echo The server encountered the words "stop for three weeks" in 
the data stream
    goto :END
:END
 
OpenText StreamServe 5.6 Updated: 2013-03-01