Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: VDEFMON

VDEFMON.m

Go to the documentation of this file.
  1. VDEFMON ;BPOIFO/JG - VDEF Queue Process Monitor ; 20 Dec 2005 13:00 PM
  1. ;;1.0;VDEF;**3**;Dec 28, 2004
  1. ;Per VHA Directive 2004-038, this routine should not be modified.
  1. ;
  1. Q ; No bozos
  1. ;
  1. START ; Main entry point for scheduling queue processor monitor in TaskMan
  1. I '$D(ZTQUEUED) W !,"Must be run from TaskMan." Q
  1. ;
  1. START1 ; Non-TaskMan entry
  1. ;
  1. ; Only one of these needs to be running.
  1. L +^VDEFHL7("REQMON"):1 Q:'$T
  1. ;
  1. ; Start the Request Queue processor monitor
  1. N ZTDESC,ZTDTH,ZTIO,ZTPRI,ZTRTN,ZTSK
  1. S ZTRTN="MONITOR^VDEFMON",(ZTIO,ZTPRI)="",ZTDTH=$H
  1. S ZTDESC="VDEF Request Processor Monitor"
  1. L -^VDEFHL7("REQMON")
  1. D ^%ZTLOAD
  1. ;
  1. ; Check that TaskMan successfully queued up the Monitor task
  1. I '$G(ZTSK) D ALERT^VDEFUTIL("VDEF QUEUE PROCESS MONITOR DID NOT START. CHECK ERROR TRAP.")
  1. Q
  1. ;
  1. ; Main entry point for the Request Queue process monitor from TaskMan.
  1. ; Check the Request Queue processor for each queue that is defined
  1. ; and has a status of "R" (running). If it is not running, send an alert
  1. ; and restart it.
  1. ; If the Request Queue is currently suspended, send an alert telling
  1. ; site to restart it.
  1. MONITOR L +^VDEFHL7("REQMON"):1 Q:'$T
  1. N QIEN,QUEFAIL,QUESTOP,VDEFTSK S VDEFTSK=ZTSK
  1. MONITOR1 S QIEN=0
  1. F S QIEN=+$O(^VDEFHL7(579.3,QIEN)) Q:'QIEN D D ALERTSUS:QUESTOP,ALERT:QUEFAIL
  1. . S (QUESTOP,QUEFAIL)=0
  1. . S QUESTOP=$P(^VDEFHL7(579.3,QIEN,0),U,9)="S" Q:QUESTOP
  1. . ;
  1. . ; Try to lock this Request Queue. If it's already locked,
  1. . ; assume that the Request queue processor is running OK.
  1. . L +^VDEFHL7(579.3,"QUEUE",QIEN):1 S QUEFAIL=$T
  1. . L -^VDEFHL7(579.3,"QUEUE",QIEN)
  1. ;
  1. ; Requeue any requests that are stuck in Checked Out or Errored Out status.
  1. S QIEN=0 N RQ
  1. F S QIEN=+$O(^VDEFHL7(579.3,QIEN)) Q:'QIEN D
  1. . I +$O(^VDEFHL7(579.3,"C","C",QIEN,"")) D
  1. .. D REQUEUE^VDEFQM(QIEN,.RQ)
  1. .. D:RQ ALERT^VDEFUTIL("VDEF HAS REQUEUED CHECKED OUT RECORDS. NO ACTION NEEDED.")
  1. . I +$O(^VDEFHL7(579.3,"C","E",QIEN,"")) D
  1. .. D RQERR^VDEFQM(QIEN,.RQ)
  1. .. D:RQ ALERT^VDEFUTIL("VDEF HAS REQUEUED ERRORED OUT RECORDS. NO ACTION NEEDED.")
  1. ;
  1. ; Wait for 10 minutes before checking the queue processors again.
  1. ; The wait process is in a loop so it can check if there
  1. ; has been a request to stop processing before the wait expires.
  1. WAITLOOP N I F I=1:1:600 D Q:ZTSTOP
  1. . S ZTSTOP=$$S^%ZTLOAD() Q:ZTSTOP
  1. . H 1
  1. ;
  1. ; Quit or resume processing
  1. G MONITOR1:'$G(ZTSTOP)
  1. ;
  1. ; Send an alert and delete this task's record
  1. EXIT D ALERT^VDEFUTIL("VDEF QUEUE PROCESS MONITOR HAS EXITED.")
  1. L -^VDEFHL7("REQMON")
  1. S ZTSK=VDEFTSK,ZTSTOP=1,ZTREQ="@"
  1. Q
  1. ;
  1. ; Generate the failure/restart alert
  1. ALERT N QUEUE,Y D ALERTDAT
  1. D ALERT^VDEFUTIL("VDEF QUEUE '"_QUEUE_"' AUTO-RESTARTED. NO ACTION REQUIRED.")
  1. ;
  1. ; Restart the Request Queue processor
  1. D REQ^VDEFCONT(QIEN)
  1. Q
  1. ;
  1. ; Generate the alert that a Request Queue is suspended.
  1. ALERTSUS N QUEUE,Y D ALERTDAT
  1. D ALERT^VDEFUTIL("VDEF QUEUE '"_QUEUE_"' IS SUSPENDED. PLEASE START IT.")
  1. Q
  1. ;
  1. ; Get the queue name
  1. ALERTDAT S QUEUE=$P(^VDEFHL7(579.3,QIEN,0),U)
  1. Q