%ZTM0 ;SEA/RDS-TaskMan: Manager, Part 2 (Begin) ;07/17/08 08:16
;;8.0;KERNEL;**42,36,67,88,118,127,136,175,275,355,446**;Jul 10, 1995;Build 35
;Per VHA Directive 2004-038, this routine should not be modified.
;
START ;Entry Point--start Task Manager at system startup
S $ETRAP="D ER^%ZTM5",^%ZTSCH("ER")="",U="^"
L ^%ZTSCH:10 G:'$T RESTART ;Someone already running
K ^%ZTSCH("DEV"),^("DEVOPEN"),^("LOAD"),^("LOADA"),^("STATUS"),^("STOP"),^("SUB"),^("UPDATE")
S %ZTIME=$$H3^%ZTM($H)
D STATUS^%ZTM("RUN","Startup") ;Move after kill p446
S %ZTLKTM=5 ;Temp value for I6^%ZTM ;p446
D I6^%ZTM ;Handle Persistent Jobs
S ZTSK=0 F S ZTSK=$O(^%ZTSCH("TASK",ZTSK)) Q:'ZTSK D
. D TSKSTAT^%ZTM1("E","Interrupted While Running")
. K ^%ZTSCH("TASK",ZTSK)
K ^%ZTSCH("TASK") ;Remove all p446
D SETUP
I "CFO"[%ZTYPE G BADTYPE ;Moved after SETUP p446
S ^%ZTSCH("IDLE")=0,^%ZTSCH("SUB",%ZTPAIR)=0,^(%ZTPAIR,0)=0
D STATUS^%ZTM("RUN","Startup Hang")
H %ZTPFLG("TM-DELAY") ;Wait for system stability.
S1 ;
D STATUS^%ZTM("RUN","Startup jobs")
;S %ZTLOOP=0,%ZTRUN=1 D CHECK^%ZTM ;Why? ;p446
D STRTUP
S ZTU="" F S ZTU=$O(^%ZTSCH("C",ZTU)) Q:ZTU="" S ^%ZTSCH("C",ZTU)=0 ;Reset VS counts in C list.
K %ZTI,%ZTY,ZTIO,ZTO,ZTP,ZTSK,ZTU
I %ZTPFLG("XUSCNT") D COUNT^XUSCNT(1)
G ^%ZTM
;
RESTART ;Entry Point--restart Task Manager
S $ETRAP="D ER^%ZTM5",^%ZTSCH("ER")="",U="^"
K ^%ZTSCH("STATUS"),^("STOP")
S %ZTIME=$$H3^%ZTM($H)
D STATUS^%ZTM("RUN","Restart") ;Move after kill p446
D SETUP
I '$D(^%ZTSCH("IDLE")) S ^%ZTSCH("IDLE")=0
I '$D(^%ZTSCH("SUB",%ZTPAIR)) S ^%ZTSCH("SUB",%ZTPAIR)=0
I "CFO"[%ZTYPE G BADTYPE
I %ZTPFLG("XUSCNT") D COUNT^XUSCNT(1)
G ^%ZTM
;
;
SETUP ;Setup Task Manager's Environment
N X,Y,Z,ZT
ST2 S ^%ZTSCH("RUN")=$H,%ZTPAIR="ROU"
D STATUS^%ZTM("RUN","Setup")
D ZOSF I Y]"" D STATUS^%ZTM("PAUSE","The following required ^%ZOSF nodes are undefined: "_Y_".") H 60 G ST2
D UPDATE^%ZTM5 I $D(ZTREQUIR)#2 D STATUS^%ZTM("PAUSE","Required link to "_ZTREQUIR_" is down.") H 60 G ST2
;Clear the NOT Responding count
S X="" F S X=$O(^%ZTSCH("C",X)) Q:X="" S ^%ZTSCH("C",X)=0
D JOB,NOLOG^%ZOSV S %ZTNLG=Y,DTIME=1,DUZ=0,DUZ(0)="@"
K Z D NAME K X,Y,Z,ZT
Q
STRTUP ;Queue the entries from the STARTUP X-ref
;After talking with the DBA, All STARTUP jobs will have DUZ=.5
N ZTU,ZTO,ZTSAVE,ZTRTN,DUZ
S DUZ=.5,DUZ(0)="@"
S ZTU="" F S ZTU=$O(^%ZTSCH("STARTUP",ZTU)),ZTO="" Q:ZTU="" F S ZTO=$O(^%ZTSCH("STARTUP",ZTU,ZTO)) Q:ZTO="" D
. S ZTSAVE("XQY")=$P(ZTO,"Q",2) ;This must be set for %ZTLOAD
. S ZTDTH=$H,ZTIO=$P(^%ZTSCH("STARTUP",ZTU,ZTO),"^",2),ZTRTN="ZTSK^XQ1",ZTSAVE($S(ZTO["Q":"XQSCH",1:"XQY"))=+ZTO,ZTUCI=$P(ZTU,","),ZTCPU=$P(ZTU,",",2)
. D ^%ZTLOAD
. Q
Q
;
ZOSF ;SETUP--determine whether any required ^%ZOSF nodes are missing
S Y=""
F X="ACTJ","OS","PROD","UCI","UCICHECK","VOL" I $D(^%ZOSF(X))[0 S Y=Y_","_X
S:$T(ACTJ^%ZOSV)="" Y=Y_",ACTJ^%ZOSV"
I Y]"" S Y=$E(Y,2,$L(Y))
Q
;
JOB ;SETUP--setup JOB command
I %ZTOS["OpenM" D Q
. S:'$L(%ZTPFLG("DCL")) %ZTJOB="J ^%ZTMS::5" ;"J ^%ZTMS:ZTUCI:5"
. S:$L(%ZTPFLG("DCL")) %ZTJOB="D ^%ZTMDCL"
. Q
I %ZTOS["GT.M" S %ZTJOB="J GTM^%ZTMS::5",@("$ZINTERRUPT=""I $$JOBEXAM^ZU($ZPOSITION)""") Q
I %ZTOS["VAX DSM" D Q
. S:'$L(%ZTPFLG("DCL")) %ZTJOB="J ^%ZTMS:(OPTION=""/UCI=""_$P(ZTUCI,"","")_""/VOL=""_ZTDVOL):5"
. S:$L(%ZTPFLG("DCL")) %ZTJOB="D ^%ZTMDCL"
. Q
I %ZTOS["MSM" S %ZTJOB="J ^%ZTMS[ZTUCI,ZTDVOL]:%ZTSIZ:5" Q ;Set Maxpartsiz
I %ZTOS["DTM" S %ZTJOB="J ^%ZTMS:(NSPACE=ZTUCI)" Q
S %ZTJOB="J ^%ZTMS::5"
Q
;
NAME ;Give a name to process.
N $ETRAP,ZQ S $ETRAP="S ZQ=0,$EC="""" Q"
F Z=1:1:9 S X="Taskman "_%ZTVOL_" "_Z,ZQ=1 D SETENV^%ZOSV Q:ZQ
Q
BADTYPE ;Taskman should not run on this type of node.
K ^%ZTSCH("STATUS")
S ^%ZTSCH("RUN")=%ZTPAIR_" is the wrong type in taskman site parameters."
Q
;
HALT ;Cleanup and halt
I %ZTPFLG("XUSCNT") D COUNT^XUSCNT(-1)
K ^%ZTSCH("STATUS",$J),^%ZTSCH("RUN"),^%ZTSCH("UPDATE",$J)
K ^%ZTSCH("LOADA",%ZTPAIR)
X "HALT"
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HZTM0 4074 printed Dec 13, 2024@02:16:06 Page 2
%ZTM0 ;SEA/RDS-TaskMan: Manager, Part 2 (Begin) ;07/17/08 08:16
+1 ;;8.0;KERNEL;**42,36,67,88,118,127,136,175,275,355,446**;Jul 10, 1995;Build 35
+2 ;Per VHA Directive 2004-038, this routine should not be modified.
+3 ;
START ;Entry Point--start Task Manager at system startup
+1 SET $ETRAP="D ER^%ZTM5"
SET ^%ZTSCH("ER")=""
SET U="^"
+2 ;Someone already running
LOCK ^%ZTSCH:10
if '$TEST
GOTO RESTART
+3 KILL ^%ZTSCH("DEV"),^("DEVOPEN"),^("LOAD"),^("LOADA"),^("STATUS"),^("STOP"),^("SUB"),^("UPDATE")
+4 SET %ZTIME=$$H3^%ZTM($HOROLOG)
+5 ;Move after kill p446
DO STATUS^%ZTM("RUN","Startup")
+6 ;Temp value for I6^%ZTM ;p446
SET %ZTLKTM=5
+7 ;Handle Persistent Jobs
DO I6^%ZTM
+8 SET ZTSK=0
FOR
SET ZTSK=$ORDER(^%ZTSCH("TASK",ZTSK))
if 'ZTSK
QUIT
Begin DoDot:1
+9 DO TSKSTAT^%ZTM1("E","Interrupted While Running")
+10 KILL ^%ZTSCH("TASK",ZTSK)
End DoDot:1
+11 ;Remove all p446
KILL ^%ZTSCH("TASK")
+12 DO SETUP
+13 ;Moved after SETUP p446
IF "CFO"[%ZTYPE
GOTO BADTYPE
+14 SET ^%ZTSCH("IDLE")=0
SET ^%ZTSCH("SUB",%ZTPAIR)=0
SET ^(%ZTPAIR,0)=0
+15 DO STATUS^%ZTM("RUN","Startup Hang")
+16 ;Wait for system stability.
HANG %ZTPFLG("TM-DELAY")
S1 ;
+1 DO STATUS^%ZTM("RUN","Startup jobs")
+2 ;S %ZTLOOP=0,%ZTRUN=1 D CHECK^%ZTM ;Why? ;p446
+3 DO STRTUP
+4 ;Reset VS counts in C list.
SET ZTU=""
FOR
SET ZTU=$ORDER(^%ZTSCH("C",ZTU))
if ZTU=""
QUIT
SET ^%ZTSCH("C",ZTU)=0
+5 KILL %ZTI,%ZTY,ZTIO,ZTO,ZTP,ZTSK,ZTU
+6 IF %ZTPFLG("XUSCNT")
DO COUNT^XUSCNT(1)
+7 GOTO ^%ZTM
+8 ;
RESTART ;Entry Point--restart Task Manager
+1 SET $ETRAP="D ER^%ZTM5"
SET ^%ZTSCH("ER")=""
SET U="^"
+2 KILL ^%ZTSCH("STATUS"),^("STOP")
+3 SET %ZTIME=$$H3^%ZTM($HOROLOG)
+4 ;Move after kill p446
DO STATUS^%ZTM("RUN","Restart")
+5 DO SETUP
+6 IF '$DATA(^%ZTSCH("IDLE"))
SET ^%ZTSCH("IDLE")=0
+7 IF '$DATA(^%ZTSCH("SUB",%ZTPAIR))
SET ^%ZTSCH("SUB",%ZTPAIR)=0
+8 IF "CFO"[%ZTYPE
GOTO BADTYPE
+9 IF %ZTPFLG("XUSCNT")
DO COUNT^XUSCNT(1)
+10 GOTO ^%ZTM
+11 ;
+12 ;
SETUP ;Setup Task Manager's Environment
+1 NEW X,Y,Z,ZT
ST2 SET ^%ZTSCH("RUN")=$HOROLOG
SET %ZTPAIR="ROU"
+1 DO STATUS^%ZTM("RUN","Setup")
+2 DO ZOSF
IF Y]""
DO STATUS^%ZTM("PAUSE","The following required ^%ZOSF nodes are undefined: "_Y_".")
HANG 60
GOTO ST2
+3 DO UPDATE^%ZTM5
IF $DATA(ZTREQUIR)#2
DO STATUS^%ZTM("PAUSE","Required link to "_ZTREQUIR_" is down.")
HANG 60
GOTO ST2
+4 ;Clear the NOT Responding count
+5 SET X=""
FOR
SET X=$ORDER(^%ZTSCH("C",X))
if X=""
QUIT
SET ^%ZTSCH("C",X)=0
+6 DO JOB
DO NOLOG^%ZOSV
SET %ZTNLG=Y
SET DTIME=1
SET DUZ=0
SET DUZ(0)="@"
+7 KILL Z
DO NAME
KILL X,Y,Z,ZT
+8 QUIT
STRTUP ;Queue the entries from the STARTUP X-ref
+1 ;After talking with the DBA, All STARTUP jobs will have DUZ=.5
+2 NEW ZTU,ZTO,ZTSAVE,ZTRTN,DUZ
+3 SET DUZ=.5
SET DUZ(0)="@"
+4 SET ZTU=""
FOR
SET ZTU=$ORDER(^%ZTSCH("STARTUP",ZTU))
SET ZTO=""
if ZTU=""
QUIT
FOR
SET ZTO=$ORDER(^%ZTSCH("STARTUP",ZTU,ZTO))
if ZTO=""
QUIT
Begin DoDot:1
+5 ;This must be set for %ZTLOAD
SET ZTSAVE("XQY")=$PIECE(ZTO,"Q",2)
+6 SET ZTDTH=$HOROLOG
SET ZTIO=$PIECE(^%ZTSCH("STARTUP",ZTU,ZTO),"^",2)
SET ZTRTN="ZTSK^XQ1"
SET ZTSAVE($SELECT(ZTO["Q":"XQSCH",1:"XQY"))=+ZTO
SET ZTUCI=$PIECE(ZTU,",")
SET ZTCPU=$PIECE(ZTU,",",2)
+7 DO ^%ZTLOAD
+8 QUIT
End DoDot:1
+9 QUIT
+10 ;
ZOSF ;SETUP--determine whether any required ^%ZOSF nodes are missing
+1 SET Y=""
+2 FOR X="ACTJ","OS","PROD","UCI","UCICHECK","VOL"
IF $DATA(^%ZOSF(X))[0
SET Y=Y_","_X
+3 if $TEXT(ACTJ^%ZOSV)=""
SET Y=Y_",ACTJ^%ZOSV"
+4 IF Y]""
SET Y=$EXTRACT(Y,2,$LENGTH(Y))
+5 QUIT
+6 ;
JOB ;SETUP--setup JOB command
+1 IF %ZTOS["OpenM"
Begin DoDot:1
+2 ;"J ^%ZTMS:ZTUCI:5"
if '$LENGTH(%ZTPFLG("DCL"))
SET %ZTJOB="J ^%ZTMS::5"
+3 if $LENGTH(%ZTPFLG("DCL"))
SET %ZTJOB="D ^%ZTMDCL"
+4 QUIT
End DoDot:1
QUIT
+5 IF %ZTOS["GT.M"
SET %ZTJOB="J GTM^%ZTMS::5"
SET @("$ZINTERRUPT=""I $$JOBEXAM^ZU($ZPOSITION)""")
QUIT
+6 IF %ZTOS["VAX DSM"
Begin DoDot:1
+7 if '$LENGTH(%ZTPFLG("DCL"))
SET %ZTJOB="J ^%ZTMS:(OPTION=""/UCI=""_$P(ZTUCI,"","")_""/VOL=""_ZTDVOL):5"
+8 if $LENGTH(%ZTPFLG("DCL"))
SET %ZTJOB="D ^%ZTMDCL"
+9 QUIT
End DoDot:1
QUIT
+10 ;Set Maxpartsiz
IF %ZTOS["MSM"
SET %ZTJOB="J ^%ZTMS[ZTUCI,ZTDVOL]:%ZTSIZ:5"
QUIT
+11 IF %ZTOS["DTM"
SET %ZTJOB="J ^%ZTMS:(NSPACE=ZTUCI)"
QUIT
+12 SET %ZTJOB="J ^%ZTMS::5"
+13 QUIT
+14 ;
NAME ;Give a name to process.
+1 NEW $ETRAP,ZQ
SET $ETRAP="S ZQ=0,$EC="""" Q"
+2 FOR Z=1:1:9
SET X="Taskman "_%ZTVOL_" "_Z
SET ZQ=1
DO SETENV^%ZOSV
if ZQ
QUIT
+3 QUIT
BADTYPE ;Taskman should not run on this type of node.
+1 KILL ^%ZTSCH("STATUS")
+2 SET ^%ZTSCH("RUN")=%ZTPAIR_" is the wrong type in taskman site parameters."
+3 QUIT
+4 ;
HALT ;Cleanup and halt
+1 IF %ZTPFLG("XUSCNT")
DO COUNT^XUSCNT(-1)
+2 KILL ^%ZTSCH("STATUS",$JOB),^%ZTSCH("RUN"),^%ZTSCH("UPDATE",$JOB)
+3 KILL ^%ZTSCH("LOADA",%ZTPAIR)
+4 XECUTE "HALT"