INHVCRV1 ;KAC,bar ; 17 Aug 95 10:35; Create Application Server (ApS)
;;3.01;BHL IHS Interfaces with GIS;;JUL 01, 2001
;COPYRIGHT 1991-2000 SAIC
;
Q
;
NEWSVR(INBPN,INV,INOA) ; Create Application Server (ApS).
;
; Input:
; INBPN - (req) BACKGROUND PROCESS CONTROL IEN for ApS
; INV - (req) array of inbound msg values to pass to server
; INOA - (req) array of outbound msg values to pass to server
;
; Variables:
; INAVJ - executable code to indicate # of available jobs on
; system, from ^%ZOSF("AVJ")
; INJCODE - executable code to initiate an Aps server
; INLSTSVR - last ApS server number used
; INMAXAPS - maximum # of Application Server (ApS) jobs
; default is 9999, our definition of infinity
; INSRVR - ApS server #
;
; Output:
; 0 - successfully created an application server
; 1 - application server NOT created
;
N L,T,S,Y,INAVJ,INJCODE,INLSTSVR,INMAXAPS,INSRVR
;
S INMAXAPS=$G(^INTHPC(INBPN,7)) ; get node with ApS startup info
Q:'+INMAXAPS 1 ; valid ApS server?
; Get last ApS server # used & max # of ApS processes
S INLSTSVR=+$P(INMAXAPS,U,3),INMAXAPS=+$P(INMAXAPS,U,2) S:'INMAXAPS INMAXAPS=9999
;
; Executable code that specifies # of available jobs on system
S INAVJ=^%ZOSF("AVJ")
;
; Check for available ApS process slot. Locked "RUN" node indicates
; that this slot is in use. Wrap to slot 1 when hit maximum slot #.
; L = flag indicating when to stop iterating thru the list of slots
; (each slot will be ck'd no more than 2 times)
; S = ApS server (slot) #
S (INSRVR,L)=0,S=INLSTSVR
F S S=S+1 S:S>INMAXAPS S=1,L=L+1 Q:L>1 L +^INRHB("RUN","SRVR",INBPN,S):0 I S INSRVR=S Q
;
; Update last ApS server # used
L +^INTHPC(INBPN):0 S $P(^INTHPC(INBPN,7),U,3)=INSRVR L -^INTHPC(INBPN)
;
; Check for available DSM process slot
S T=0 I INSRVR X INAVJ I Y>1 D S Y=$$INRHB^INHUVUT1(INBPN,"",T) ; clr status, T=1 logs success
. ; T is startup flag
. S T=1,^INRHB("RUN",INBPN)=$H_"^Starting server "_INSRVR,^INRHB("RUN","SRVR",INBPN,INSRVR)=$H_"^Attempting to start server"
. ; get program to build job code
. N INPROG S INPROG=$G(^INTHPC(INBPN,"ROU"))
. ; verify program and execute, $T should be set from JOB command
. I $L(INPROG) D @INPROG I 1 X INJCODE S T=$T Q
. S T=0
L -^INRHB("RUN","SRVR",INBPN,S)
Q '(T&INSRVR)
;
PWSSRVR ; build executable code to start PWS server
;
; INV - array of inbound msg values to pass to server
; ZIL2 = IP address of remote system
; ZIL3 = port of remote system
; INOA - array of outbound msg values to pass to server
; ZIL4 = remote user (DUZ)
; ZIL10 = key/ticket value for verification
;
S INJCODE=$$REPLACE^UTIL(^INTHOS(1,1),"*","EN^INHVCRA("_INBPN_","_INSRVR_","""_@INV@("ZIL2")_""","_@INV@("ZIL3")_","""_INOA("ZIL10")_""","_INOA("ZIL4")_")")
Q
INHVCRV1 ;KAC,bar ; 17 Aug 95 10:35; Create Application Server (ApS)
+1 ;;3.01;BHL IHS Interfaces with GIS;;JUL 01, 2001
+2 ;COPYRIGHT 1991-2000 SAIC
+3 ;
+4 QUIT
+5 ;
NEWSVR(INBPN,INV,INOA) ; Create Application Server (ApS).
+1 ;
+2 ; Input:
+3 ; INBPN - (req) BACKGROUND PROCESS CONTROL IEN for ApS
+4 ; INV - (req) array of inbound msg values to pass to server
+5 ; INOA - (req) array of outbound msg values to pass to server
+6 ;
+7 ; Variables:
+8 ; INAVJ - executable code to indicate # of available jobs on
+9 ; system, from ^%ZOSF("AVJ")
+10 ; INJCODE - executable code to initiate an Aps server
+11 ; INLSTSVR - last ApS server number used
+12 ; INMAXAPS - maximum # of Application Server (ApS) jobs
+13 ; default is 9999, our definition of infinity
+14 ; INSRVR - ApS server #
+15 ;
+16 ; Output:
+17 ; 0 - successfully created an application server
+18 ; 1 - application server NOT created
+19 ;
+20 NEW L,T,S,Y,INAVJ,INJCODE,INLSTSVR,INMAXAPS,INSRVR
+21 ;
+22 ; get node with ApS startup info
SET INMAXAPS=$GET(^INTHPC(INBPN,7))
+23 ; valid ApS server?
IF '+INMAXAPS
QUIT 1
+24 ; Get last ApS server # used & max # of ApS processes
+25 SET INLSTSVR=+$PIECE(INMAXAPS,U,3)
SET INMAXAPS=+$PIECE(INMAXAPS,U,2)
IF 'INMAXAPS
SET INMAXAPS=9999
+26 ;
+27 ; Executable code that specifies # of available jobs on system
+28 SET INAVJ=^%ZOSF("AVJ")
+29 ;
+30 ; Check for available ApS process slot. Locked "RUN" node indicates
+31 ; that this slot is in use. Wrap to slot 1 when hit maximum slot #.
+32 ; L = flag indicating when to stop iterating thru the list of slots
+33 ; (each slot will be ck'd no more than 2 times)
+34 ; S = ApS server (slot) #
+35 SET (INSRVR,L)=0
SET S=INLSTSVR
+36 FOR
SET S=S+1
IF S>INMAXAPS
SET S=1
SET L=L+1
IF L>1
QUIT
LOCK +^INRHB("RUN","SRVR",INBPN,S):0
IF $TEST
SET INSRVR=S
QUIT
+37 ;
+38 ; Update last ApS server # used
+39 LOCK +^INTHPC(INBPN):0
SET $PIECE(^INTHPC(INBPN,7),U,3)=INSRVR
LOCK -^INTHPC(INBPN)
+40 ;
+41 ; Check for available DSM process slot
+42 ; clr status, T=1 logs success
SET T=0
IF INSRVR
XECUTE INAVJ
IF Y>1
Begin DoDot:1
+43 ; T is startup flag
+44 SET T=1
SET ^INRHB("RUN",INBPN)=$HOROLOG_"^Starting server "_INSRVR
SET ^INRHB("RUN","SRVR",INBPN,INSRVR)=$HOROLOG_"^Attempting to start server"
+45 ; get program to build job code
+46 NEW INPROG
SET INPROG=$GET(^INTHPC(INBPN,"ROU"))
+47 ; verify program and execute, $T should be set from JOB command
+48 IF $LENGTH(INPROG)
DO @INPROG
IF 1
XECUTE INJCODE
SET T=$TEST
QUIT
+49 SET T=0
End DoDot:1
SET Y=$$INRHB^INHUVUT1(INBPN,"",T)
+50 LOCK -^INRHB("RUN","SRVR",INBPN,S)
+51 QUIT '(T&INSRVR)
+52 ;
PWSSRVR ; build executable code to start PWS server
+1 ;
+2 ; INV - array of inbound msg values to pass to server
+3 ; ZIL2 = IP address of remote system
+4 ; ZIL3 = port of remote system
+5 ; INOA - array of outbound msg values to pass to server
+6 ; ZIL4 = remote user (DUZ)
+7 ; ZIL10 = key/ticket value for verification
+8 ;
+9 SET INJCODE=$$REPLACE^UTIL(^INTHOS(1,1),"*","EN^INHVCRA("_INBPN_","_INSRVR_","""_@INV@("ZIL2")_""","_@INV@("ZIL3")_","""_INOA("ZIL10")_""","_INOA("ZIL4")_")")
+10 QUIT