-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathRestStartOn.tlpp
74 lines (54 loc) · 1.56 KB
/
RestStartOn.tlpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#INCLUDE "TOTVS.CH"
/*/{Protheus.doc} RestStartOn
Job para ativação de ws Rest
//Job que realiza ativação de Thread no Rest
@type function
@version 1.0.0
@author Endreo Figueiredo
@since 09/11/2021
//Configuração
[ONSTART]
JOBS=HTTPJOB, MONITORWS
REFRESHRATE=10
[MONITORWS]
MAIN=U_RestStartOn
ENVIRONMENT=TESTE005
nParms=2
Parm1=01 //Empresa
Parm2=01 //Filial
/*/
User Function RestStartOn(cEmp,cFil)
Local nSeconds := Seconds()
Local lContinua := .T.
Local cHoraIni := SubsTr(Time(),1,2)
Local oRestOn := Nil
Local aHeader := {}
Local cJson := ''
Default cEmp := "01"
Default cFil := "01"
If ! Empty(cEmp)
RPCSetType(3) // Nao comer licensa
RPCSetEnv(cEmp,cFil,,,"FIN")
EndIf
While lContinua
nSeconds := Seconds()
oRestOn := FWRest():New('http://localhost:5890/rest')
oRestOn:SetPath("/healthcheck")
varinfo('GET', oRestOn:Get(aHeader) )
If ValType(oRestOn) == "O"
VarInfo('SERVICO EM OPERACAO' , oRestOn )
cJson := oRestOn:GetResult()
VarInfo("json: " , cJson )
VarInfo("-----------------------------------------------------------")
VarInfo("Tempo MS",Seconds()-nSeconds)
VarInfo("-----------------------------------------------------------")
Else
VarInfo(oRestOn:GetLastError() , " Sem conexo com WS " )
EndIf
lContinua := (cHoraIni == SubsTr(Time(),1,2))
oRestOn := Nil
//FreeObj(oRestOn)
Sleep(30000)
EndDo
RpcClearEnv()
Return