project BLF > class TDaemonUtility > method StopDaemon
Description
Send a stop request to all running instances of a daemon.
Parameters
icDaemonName | input | character | Name of the daemon to be stopped |
ocMessage | output | character | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
BLF
program code (program1/tdaemonutility.p)
/* ================== */
/* Exception handling */
/* ================== */
assign oiReturnStatus = -98.
/* ============================================= */
/* Get info on how the daemon should bhe started */
/* ============================================= */
<Q-1 run DaemonLoginInfo (all) (Read) (NoCache)
(input icDaemonName, (DaemonName)
output dataset tqDaemonLoginInfo) in BBaseDaemon >
/* ================================================================================================================ */
/* First activate the persistence-layer when this was not yet the case - code copied from business.startpersistence */
/* ================================================================================================================ */
run StartPersistenceInPool (input {&TARGETPROCEDURE},
output vhFcComponent,
output viFcReturnSuper).
if viFcReturnSuper < 0
then do :
assign ocMessage = trim(#T-3'Cannot activate the persistence layer.':120(4389)t-3#)
oiReturnStatus = -3.
return.
end. /* if viFcReturnSuper < 0 */
/* ============================================================================================== */
/* Set the daemon-status to Stopping so the actual daemon-process will stop working */
/* ============================================================================================== */
find first tqDaemonLoginInfo no-error.
if available tqDaemonLoginInfo
then do:
<M-2 run WriteDirect
(input 'fcDaemon':U (icTableName),
input 'for each fcDaemon where fcDaemon.DaemonId = ':U + string(tqDaemonLoginInfo.tiDaemonId) (icPrepare),
input 'DaemonStatus':U (icFieldList),
input 'c':U (icFieldListDataTypes),
input {&DAEMONSTATUS-STOPPING} (icAbsolute),
input '' (icIncremental),
input {&TARGETPROCEDURE} (ihClass),
input 'StopDaemon':U (icUserLogin),
output viFcReturnSuper (oiReturnStatus)) in persistence>
if viFcReturnSuper < 0
then do:
assign ocMessage = trim(substitute(#T-89'Failed to send a stop request for daemon (&1).':100(5162)T-89#,icDaemonName))
oiReturnStatus = viFcReturnSuper.
return.
end. /* Not if viFcReturnSuper = 0 */
else assign ocMessage = trim (substitute(#T-4'A stop request for the daemon (&1) was sent.':100(5161)T-4#,icDaemonName)).
end. /* if available tqDaemonLoginInfo */
/* ================== */
/* Exception handling */
/* ================== */
if oiReturnStatus = -98
then assign oiReturnStatus = 0.