ZTMB ;SEA/RDS-Taskman: Manager, Boot/ Option, ZTMRESTART ;10/07/08 16:13
;;8.0;KERNEL;**275,355,446**;Jul 10, 1995;Build 35
;;Per VHA Directive 2004-038, this routine should not be modified.
;
START ;Start Taskmanager
N %,X,Z,ZTOS,ZTMB,ZTUCI,ZTMODE,ZTPAIR,ZTVOL,ZTNODE,ZTMULT
D INIT S ZTMB="START"
I ZTOS["OpenM" G CACHE
I ZTOS["VAX DSM" G VXD
I ZTOS["GT.M" J START^%ZTM0 Q
I ZTOS["DTM" G DTM
I $L($T(START^%ZTM0)) J START^%ZTM0 Q
W !,"Taskman NOT Started"
Q
VXD S %=($ZC(%GETJPI,$J,"CURPRIV")["SHARE") I % W !,"Don't start TaskMan with the SHARE privilege" Q
S Z=0,%=$O(^%ZIS(14.7,"B",ZTPAIR,0)),ZTMODE=$P($G(^%ZIS(14.7,+%,0)),U,10)
VXD2 I Z,$$EC^%ZOSV["access not authorized"!($$EC^%ZOSV["no privilege") W !!,"You lack the system privilege to start TaskMan." H 2 Q
I Z,$$EC^%ZOSV'["duplicate name" W !!,"The following error has prevented TaskMan from starting:",!,$$EC^%ZOSV H 2 Q
S X="VXD2",@^%ZOSF("TRAP"),Z=Z+1
I ZTMODE="" S %=ZTMB_"^%ZTM0:(OPTION=""/UCI=""_ZTUCI,NAME=""TaskMan ""_$E(^%ZOSF(""VOL""),1,3)_"" ""_Z)" J @% Q
;Remove the '/NOLOG' if you want a log file for trouble shooting
I $L(ZTMODE) S %SPAWN="SUBMIT/NOPRINT/NOLOG/USER=TASKMAN/QUEUE=TM$"_ZTNODE_" DHCP$TASKMAN:ZTMWDCL/PARAM=("_ZTMODE_","_(ZTMB["RE")_")" D ^%SPAWN
Q
;
CACHE ;Cache or OpenM
I $ZV'["VMS" J START^%ZTM0 Q ;Non-VMS start in current namespace
;For Cache/VMS
S Z=0,%=$O(^%ZIS(14.7,"B",ZTPAIR,0)),ZTMODE=$P($G(^%ZIS(14.7,+%,0)),U,10)
I '$L(ZTMODE) D Q ;Non-DCL Start
. S %=($ZF("GETJPI",$J,"PROCPRIV")["SHARE")
. I % W !,"Don't start TaskMan with the SHARE privilege" Q
. J START^%ZTM0
. Q
I $L(ZTMODE) D
. N CONF S CONF=$P(ZTPAIR,":",2)
. ;Remove the '/NOLOG' if you want a log file for trouble shooting
. S %SPAWN="SUBMIT/NOPRINT/NOLOG/USER=TASKMAN/QUEUE=TM$"_ZTNODE_" DHCP$TASKMAN:ZTM2WDCL.COM/PARAM=("_CONF_","_ZTUCI_",0)"
. S %=$ZF(-1,%SPAWN)
Q
;
DTM ;For DTM only
N DEV,NULLDEV
I ZTMB="START" D NULLDEV F DEV=10:1:19 O DEV:("W":NULLDEV):0 C DEV
S Z=0
DTM2 S X="DTM2",@^%ZOSF("TRAP"),Z=Z+1,%=ZTMB_"^%ZTM0:(NSPACE="""_ZTUCI_""":STRSTK=8000:LVMEM=12000:NAME=""TaskMan "_$E(^%ZOSF("VOL"),1,3)_" "_Z_""")" J @% Q
;
RESTART ;Restart Taskmanager
N %,%ZTI,X,Z,ZTOS,ZTMB,ZTUCI,ZTMODE,ZTPAIR,ZTVOL,ZTNODE,ZTMULT
D INIT
I $D(^%ZOSF("SIGNOFF")) X ^("SIGNOFF") I D Q
. W $C(7),!,"NOTE THAT THE SYSTEM IS IN A 'SIGNOFF' STATE,",!?4,"WHICH PROBABLY EXPLAINS WHY TASKS ARE NOT RUNNING!!",!
S ZTMULT=0
I $S($D(^%ZTSCH("RUN"))[0:0,^("RUN")-$H:0,1:$P($H,",",2)-150'>$P(^("RUN"),",",2)) W !,"TASKMAN IS ALREADY RUNNING" S ZTMULT=1
I ZTOS["VAX DSM" I $ZC(%GETJPI,$J,"CURPRIV")["SHARE" D Q
. W !,"Don't start TaskMan with the SHARE privilege" Q
I ZTOS["OpenM",$ZV["VMS" I $ZF("GETJPI",$J,"PROCPRIV")["SHARE" D Q
. W !,"Don't start TaskMan with the SHARE privilege" Q
F %ZTI=0:0 D Q:"YESyes^NOno"[%Y
. W !,"ARE YOU SURE YOU WANT TO RESTART ",$S(ZTMULT:"ANOTHER ",1:""),"TASKMAN? NO//"
. R %Y:$S($D(DTIME)#2:DTIME,1:60) S:'$T %Y="^" Q:"YESyes^NOno"[%Y
. W:'$T "*TIMEOUT*" W:%Y'["?" *7 D HELP1:%Y'["??",HELP2:%Y["??"
I %Y=""!("YESyes"'[%Y) W " (NO)",!,*7,"<NO ACTION TAKEN>",! Q
W " (YES)",!,"Restarting..."
S ZTMB="RESTART"
I ZTOS["OpenM" D CACHE,DONE Q
I ZTOS["DTM" G DTM
I ZTOS["GT.M" J RESTART^%ZTM0 D DONE Q
I ZTOS'["VAX DSM" J RESTART^%ZTM0[ZTUCI] D DONE Q
I ZTOS["VAX DSM" G VXD
W !!,$C(7),"Taskman NOT Restared",!
Q
INIT S U="^",ZTOS=^%ZOSF("OS"),ZTUCI=$P(^%ZOSF("MGR"),",")
D GETENV^%ZOSV S ZTVOL=$P(Y,U,2),ZTNODE=$P(Y,U,3),ZTPAIR=$P(Y,U,4)
Q
;
;NOTE: On DataTree systems:
;For automatic startup of TaskMan at boot, save as %ustart in SYS.
;In %ustart, remove ';' from the next two lines:
;I $P($ZVER,"/",2)>4.0,$P($ZVER,"/",2)<4.3 VIEW 1:296:$C(2) ;increase name table allocation
;I ZZSWITCH 256 ;display current namespace
;
NULLDEV ;SELECT NULL DEVICE (DTM OS Dependent)
N %HW
D HWTYPE S NULLDEV="NUL" I %HW'="PC" S NULLDEV="[NUL]"
Q
;
HWTYPE ;HARDWARE TYPE(DTM OS Dependent)
K %HW S %H=$S($P($ZVER,"/",2)<4:$V(4,3,-1),1:$V(1,3,-1)) ;get hardware type number
S %HW=$S(%H<10:"WS",%H<20:"MF",%H<64:"?",%H<129:"PC",1:"?")
Q
;
HELP1 ;RESTART--improved help for the confirmation prompt.
W !!?5,"Answer must be YES or NO."
W !?5,"Answer YES to restart ",$S(ZTMULT:"another ",1:""),"TaskMan.",!
Q
;
HELP2 ;RESTART--??-help for confirmation prompt
W !!?5,"TaskMan must be running in each library uci on the system for tasks to run."
W !?5,"One TaskMan per library uci should be enough for all but the busiest sites."
W !?5,"The System Status option and the Monitor TaskMan option can help determine"
W !?5,"whether a TaskMan is running on this volume set."
W !!?5,"If you are still uncertain how to respond, answer NO and consult your"
W !?5,"documentation or your support ISC.",!
Q
;
DONE ;RESTART--feedback after restarting TaskMan
W "TaskMan restarted!",! Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HZTMB 4945 printed Nov 22, 2024@17:26:20 Page 2
ZTMB ;SEA/RDS-Taskman: Manager, Boot/ Option, ZTMRESTART ;10/07/08 16:13
+1 ;;8.0;KERNEL;**275,355,446**;Jul 10, 1995;Build 35
+2 ;;Per VHA Directive 2004-038, this routine should not be modified.
+3 ;
START ;Start Taskmanager
+1 NEW %,X,Z,ZTOS,ZTMB,ZTUCI,ZTMODE,ZTPAIR,ZTVOL,ZTNODE,ZTMULT
+2 DO INIT
SET ZTMB="START"
+3 IF ZTOS["OpenM"
GOTO CACHE
+4 IF ZTOS["VAX DSM"
GOTO VXD
+5 IF ZTOS["GT.M"
JOB START^%ZTM0
QUIT
+6 IF ZTOS["DTM"
GOTO DTM
+7 IF $LENGTH($TEXT(START^%ZTM0))
JOB START^%ZTM0
QUIT
+8 WRITE !,"Taskman NOT Started"
+9 QUIT
VXD SET %=($ZC(%GETJPI,$JOB,"CURPRIV")["SHARE")
IF %
WRITE !,"Don't start TaskMan with the SHARE privilege"
QUIT
+1 SET Z=0
SET %=$ORDER(^%ZIS(14.7,"B",ZTPAIR,0))
SET ZTMODE=$PIECE($GET(^%ZIS(14.7,+%,0)),U,10)
VXD2 IF Z
IF $$EC^%ZOSV["access not authorized"!($$EC^%ZOSV["no privilege")
WRITE !!,"You lack the system privilege to start TaskMan."
HANG 2
QUIT
+1 IF Z
IF $$EC^%ZOSV'["duplicate name"
WRITE !!,"The following error has prevented TaskMan from starting:",!,$$EC^%ZOSV
HANG 2
QUIT
+2 SET X="VXD2"
SET @^%ZOSF("TRAP")
SET Z=Z+1
+3 IF ZTMODE=""
SET %=ZTMB_"^%ZTM0:(OPTION=""/UCI=""_ZTUCI,NAME=""TaskMan ""_$E(^%ZOSF(""VOL""),1,3)_"" ""_Z)"
JOB @%
QUIT
+4 ;Remove the '/NOLOG' if you want a log file for trouble shooting
+5 IF $LENGTH(ZTMODE)
SET %SPAWN="SUBMIT/NOPRINT/NOLOG/USER=TASKMAN/QUEUE=TM$"_ZTNODE_" DHCP$TASKMAN:ZTMWDCL/PARAM=("_ZTMODE_","_(ZTMB["RE")_")"
DO ^%SPAWN
+6 QUIT
+7 ;
CACHE ;Cache or OpenM
+1 ;Non-VMS start in current namespace
IF $ZV'["VMS"
JOB START^%ZTM0
QUIT
+2 ;For Cache/VMS
+3 SET Z=0
SET %=$ORDER(^%ZIS(14.7,"B",ZTPAIR,0))
SET ZTMODE=$PIECE($GET(^%ZIS(14.7,+%,0)),U,10)
+4 ;Non-DCL Start
IF '$LENGTH(ZTMODE)
Begin DoDot:1
+5 SET %=($ZF("GETJPI",$JOB,"PROCPRIV")["SHARE")
+6 IF %
WRITE !,"Don't start TaskMan with the SHARE privilege"
QUIT
+7 JOB START^%ZTM0
+8 QUIT
End DoDot:1
QUIT
+9 IF $LENGTH(ZTMODE)
Begin DoDot:1
+10 NEW CONF
SET CONF=$PIECE(ZTPAIR,":",2)
+11 ;Remove the '/NOLOG' if you want a log file for trouble shooting
+12 SET %SPAWN="SUBMIT/NOPRINT/NOLOG/USER=TASKMAN/QUEUE=TM$"_ZTNODE_" DHCP$TASKMAN:ZTM2WDCL.COM/PARAM=("_CONF_","_ZTUCI_",0)"
+13 SET %=$ZF(-1,%SPAWN)
End DoDot:1
+14 QUIT
+15 ;
DTM ;For DTM only
+1 NEW DEV,NULLDEV
+2 IF ZTMB="START"
DO NULLDEV
FOR DEV=10:1:19
OPEN DEV:("W":NULLDEV):0
CLOSE DEV
+3 SET Z=0
DTM2 SET X="DTM2"
SET @^%ZOSF("TRAP")
SET Z=Z+1
SET %=ZTMB_"^%ZTM0:(NSPACE="""_ZTUCI_""":STRSTK=8000:LVMEM=12000:NAME=""TaskMan "_$EXTRACT(^%ZOSF("VOL"),1,3)_" "_Z_""")"
JOB @%
QUIT
+1 ;
RESTART ;Restart Taskmanager
+1 NEW %,%ZTI,X,Z,ZTOS,ZTMB,ZTUCI,ZTMODE,ZTPAIR,ZTVOL,ZTNODE,ZTMULT
+2 DO INIT
+3 IF $DATA(^%ZOSF("SIGNOFF"))
XECUTE ^("SIGNOFF")
IF $TEST
Begin DoDot:1
+4 WRITE $CHAR(7),!,"NOTE THAT THE SYSTEM IS IN A 'SIGNOFF' STATE,",!?4,"WHICH PROBABLY EXPLAINS WHY TASKS ARE NOT RUNNING!!",!
End DoDot:1
QUIT
+5 SET ZTMULT=0
+6 IF $SELECT($DATA(^%ZTSCH("RUN"))[0:0,^("RUN")-$HOROLOG:0,1:$PIECE($HOROLOG,",",2)-150'>$PIECE(^("RUN"),",",2))
WRITE !,"TASKMAN IS ALREADY RUNNING"
SET ZTMULT=1
+7 IF ZTOS["VAX DSM"
IF $ZC(%GETJPI,$JOB,"CURPRIV")["SHARE"
Begin DoDot:1
+8 WRITE !,"Don't start TaskMan with the SHARE privilege"
QUIT
End DoDot:1
QUIT
+9 IF ZTOS["OpenM"
IF $ZV["VMS"
IF $ZF("GETJPI",$JOB,"PROCPRIV")["SHARE"
Begin DoDot:1
+10 WRITE !,"Don't start TaskMan with the SHARE privilege"
QUIT
End DoDot:1
QUIT
+11 FOR %ZTI=0:0
Begin DoDot:1
+12 WRITE !,"ARE YOU SURE YOU WANT TO RESTART ",$SELECT(ZTMULT:"ANOTHER ",1:""),"TASKMAN? NO//"
+13 READ %Y:$SELECT($DATA(DTIME)#2:DTIME,1:60)
if '$TEST
SET %Y="^"
if "YESyes^NOno"[%Y
QUIT
+14 if '$TEST
WRITE "*TIMEOUT*"
if %Y'["?"
WRITE *7
if %Y'["??"
DO HELP1
if %Y["??"
DO HELP2
End DoDot:1
if "YESyes^NOno"[%Y
QUIT
+15 IF %Y=""!("YESyes"'[%Y)
WRITE " (NO)",!,*7,"<NO ACTION TAKEN>",!
QUIT
+16 WRITE " (YES)",!,"Restarting..."
+17 SET ZTMB="RESTART"
+18 IF ZTOS["OpenM"
DO CACHE
DO DONE
QUIT
+19 IF ZTOS["DTM"
GOTO DTM
+20 IF ZTOS["GT.M"
JOB RESTART^%ZTM0
DO DONE
QUIT
+21 IF ZTOS'["VAX DSM"
JOB RESTART^%ZTM0[ZTUCI]
DO DONE
QUIT
+22 IF ZTOS["VAX DSM"
GOTO VXD
+23 WRITE !!,$CHAR(7),"Taskman NOT Restared",!
+24 QUIT
INIT SET U="^"
SET ZTOS=^%ZOSF("OS")
SET ZTUCI=$PIECE(^%ZOSF("MGR"),",")
+1 DO GETENV^%ZOSV
SET ZTVOL=$PIECE(Y,U,2)
SET ZTNODE=$PIECE(Y,U,3)
SET ZTPAIR=$PIECE(Y,U,4)
+2 QUIT
+3 ;
+4 ;NOTE: On DataTree systems:
+5 ;For automatic startup of TaskMan at boot, save as %ustart in SYS.
+6 ;In %ustart, remove ';' from the next two lines:
+7 ;I $P($ZVER,"/",2)>4.0,$P($ZVER,"/",2)<4.3 VIEW 1:296:$C(2) ;increase name table allocation
+8 ;I ZZSWITCH 256 ;display current namespace
+9 ;
NULLDEV ;SELECT NULL DEVICE (DTM OS Dependent)
+1 NEW %HW
+2 DO HWTYPE
SET NULLDEV="NUL"
IF %HW'="PC"
SET NULLDEV="[NUL]"
+3 QUIT
+4 ;
HWTYPE ;HARDWARE TYPE(DTM OS Dependent)
+1 ;get hardware type number
KILL %HW
SET %H=$SELECT($PIECE($ZVER,"/",2)<4:$VIEW(4,3,-1),1:$VIEW(1,3,-1))
+2 SET %HW=$SELECT(%H<10:"WS",%H<20:"MF",%H<64:"?",%H<129:"PC",1:"?")
+3 QUIT
+4 ;
HELP1 ;RESTART--improved help for the confirmation prompt.
+1 WRITE !!?5,"Answer must be YES or NO."
+2 WRITE !?5,"Answer YES to restart ",$SELECT(ZTMULT:"another ",1:""),"TaskMan.",!
+3 QUIT
+4 ;
HELP2 ;RESTART--??-help for confirmation prompt
+1 WRITE !!?5,"TaskMan must be running in each library uci on the system for tasks to run."
+2 WRITE !?5,"One TaskMan per library uci should be enough for all but the busiest sites."
+3 WRITE !?5,"The System Status option and the Monitor TaskMan option can help determine"
+4 WRITE !?5,"whether a TaskMan is running on this volume set."
+5 WRITE !!?5,"If you are still uncertain how to respond, answer NO and consult your"
+6 WRITE !?5,"documentation or your support ISC.",!
+7 QUIT
+8 ;
DONE ;RESTART--feedback after restarting TaskMan
+1 WRITE "TaskMan restarted!",!
QUIT
+2 ;