source: WorldVistAEHR/trunk/r/VDEF-VDEF/VDEFMON.m@ 1078

Last change on this file since 1078 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 3.0 KB
RevLine 
[613]1VDEFMON ;BPOIFO/JG - VDEF Queue Process Monitor ; 20 Dec 2005 13:00 PM
2 ;;1.0;VDEF;**3**;Dec 28, 2004
3 ;Per VHA Directive 2004-038, this routine should not be modified.
4 ;
5 Q ; No bozos
6 ;
7START ; Main entry point for scheduling queue processor monitor in TaskMan
8 I '$D(ZTQUEUED) W !,"Must be run from TaskMan." Q
9 ;
10START1 ; Non-TaskMan entry
11 ;
12 ; Only one of these needs to be running.
13 L +^VDEFHL7("REQMON"):1 Q:'$T
14 ;
15 ; Start the Request Queue processor monitor
16 N ZTDESC,ZTDTH,ZTIO,ZTPRI,ZTRTN,ZTSK
17 S ZTRTN="MONITOR^VDEFMON",(ZTIO,ZTPRI)="",ZTDTH=$H
18 S ZTDESC="VDEF Request Processor Monitor"
19 L -^VDEFHL7("REQMON")
20 D ^%ZTLOAD
21 ;
22 ; Check that TaskMan successfully queued up the Monitor task
23 I '$G(ZTSK) D ALERT^VDEFUTIL("VDEF QUEUE PROCESS MONITOR DID NOT START. CHECK ERROR TRAP.")
24 Q
25 ;
26 ; Main entry point for the Request Queue process monitor from TaskMan.
27 ; Check the Request Queue processor for each queue that is defined
28 ; and has a status of "R" (running). If it is not running, send an alert
29 ; and restart it.
30 ; If the Request Queue is currently suspended, send an alert telling
31 ; site to restart it.
32MONITOR L +^VDEFHL7("REQMON"):1 Q:'$T
33 N QIEN,QUEFAIL,QUESTOP,VDEFTSK S VDEFTSK=ZTSK
34MONITOR1 S QIEN=0
35 F S QIEN=+$O(^VDEFHL7(579.3,QIEN)) Q:'QIEN D D ALERTSUS:QUESTOP,ALERT:QUEFAIL
36 . S (QUESTOP,QUEFAIL)=0
37 . S QUESTOP=$P(^VDEFHL7(579.3,QIEN,0),U,9)="S" Q:QUESTOP
38 . ;
39 . ; Try to lock this Request Queue. If it's already locked,
40 . ; assume that the Request queue processor is running OK.
41 . L +^VDEFHL7(579.3,"QUEUE",QIEN):1 S QUEFAIL=$T
42 . L -^VDEFHL7(579.3,"QUEUE",QIEN)
43 ;
44 ; Requeue any requests that are stuck in Checked Out or Errored Out status.
45 S QIEN=0 N RQ
46 F S QIEN=+$O(^VDEFHL7(579.3,QIEN)) Q:'QIEN D
47 . I +$O(^VDEFHL7(579.3,"C","C",QIEN,"")) D
48 .. D REQUEUE^VDEFQM(QIEN,.RQ)
49 .. D:RQ ALERT^VDEFUTIL("VDEF HAS REQUEUED CHECKED OUT RECORDS. NO ACTION NEEDED.")
50 . I +$O(^VDEFHL7(579.3,"C","E",QIEN,"")) D
51 .. D RQERR^VDEFQM(QIEN,.RQ)
52 .. D:RQ ALERT^VDEFUTIL("VDEF HAS REQUEUED ERRORED OUT RECORDS. NO ACTION NEEDED.")
53 ;
54 ; Wait for 10 minutes before checking the queue processors again.
55 ; The wait process is in a loop so it can check if there
56 ; has been a request to stop processing before the wait expires.
57WAITLOOP N I F I=1:1:600 D Q:ZTSTOP
58 . S ZTSTOP=$$S^%ZTLOAD() Q:ZTSTOP
59 . H 1
60 ;
61 ; Quit or resume processing
62 G MONITOR1:'$G(ZTSTOP)
63 ;
64 ; Send an alert and delete this task's record
65EXIT D ALERT^VDEFUTIL("VDEF QUEUE PROCESS MONITOR HAS EXITED.")
66 L -^VDEFHL7("REQMON")
67 S ZTSK=VDEFTSK,ZTSTOP=1,ZTREQ="@"
68 Q
69 ;
70 ; Generate the failure/restart alert
71ALERT N QUEUE,Y D ALERTDAT
72 D ALERT^VDEFUTIL("VDEF QUEUE '"_QUEUE_"' AUTO-RESTARTED. NO ACTION REQUIRED.")
73 ;
74 ; Restart the Request Queue processor
75 D REQ^VDEFCONT(QIEN)
76 Q
77 ;
78 ; Generate the alert that a Request Queue is suspended.
79ALERTSUS N QUEUE,Y D ALERTDAT
80 D ALERT^VDEFUTIL("VDEF QUEUE '"_QUEUE_"' IS SUSPENDED. PLEASE START IT.")
81 Q
82 ;
83 ; Get the queue name
84ALERTDAT S QUEUE=$P(^VDEFHL7(579.3,QIEN,0),U)
85 Q
Note: See TracBrowser for help on using the repository browser.