Dim WshShell, fso, AccessInfoFile, oExec, oRun, oCosmiHome, oMngsvrc, oMngsvut, oCjsleep, oMngHost
Set WshShell = CreateObject("WScript.Shell")
oCosmiHome = WshShell.ExpandEnvironmentStrings("%COSMINEXUS_HOME%")
oMngsvrc = """" & oCosmiHome & "¥manager¥bin¥mngsvrctl"""
oMngsvut = """" & oCosmiHome & "¥manager¥bin¥mngsvrutil"""
oCjsleep = """" & oCosmiHome & "¥CC¥server¥bin¥cjsleep"""
oMngHost = "192.168.255.111" '--- Management Server
' ==== Open ====
Function Open( )
Resource.LogInformation "======== Entering Open. ========"
Open = True
End Function
' ==== Online ====
Function Online( )
Resource.LogInformation "======== Entering Online. ========"
'--- mngsvrctl ---
Set oExec = WshShell.Exec(oMngsvrc & " start")
Resource.LogInformation "### Management Server get starting. ### "
Retries = 20
For i=0 to Retries
oRun = oMngsvut & " -m " & oMngHost & ":28080 check mngsvr"
Set oExec = WshShell.Exec(oRun)
Do While oExec.Status = 0
WshShell.Run oCjsleep & " 10", 0, True
Loop
If oExec.ExitCode = 0 Then
Resource.LogInformation "### Management Server started. ### rtn=" & oExec.ExitCode
Resource.LogInformation oExec.StdErr.ReadAll
Exit For
End If
Next
If i > Retries Then
Resource.LogInformation "### Management Server cannot start. ### rtn=" & oExec.ExitCode
Resource.LogInformation oExec.StdOut.ReadAll
End If
Online = True
End Function
' ==== LooksAlive ====
Function LooksAlive( )
Resource.LogInformation "======== Entering LooksAlive. ========"
'--- tasklist ---
Set oExec = WshShell.Exec("tasklist /NH /FI ""IMAGENAME eq mngsvr.exe""")
Do While oExec.Status = 0
WshShell.Run oCjsleep & " 1", 0, True
Loop
If InStr(1, oExec.StdOut.ReadAll, "mngsvr.exe", 1) <> 0 Then
LooksAlive = True
Else
LooksAlive = False
End If
End Function
' ==== IsAlive ====
Function IsAlive( )
Resource.LogInformation "======== Entering IsAlive. ========"
'--- mngsvrutil ---
oRun = oMngsvut & " -m " & oMngHost & ":28080 check mngsvr"
Set oExec = WshShell.Exec(oRun)
Do While oExec.Status = 0
WshShell.Run oCjsleep & " 1", 0, True
Loop
If oExec.ExitCode <> 0 Then
Resource.LogInformation "### Management Server command failed. ### rtn=" & oExec.ExitCode
Resource.LogInformation oExec.StdErr.ReadAll
IsAlive = False
Else
IsAlive = True
End If
End Function
' ==== Offline ====
Function Offline( )
Resource.LogInformation "======== Entering Offline. ========"
'--- mngsvrctl ---
Set oExec = WshShell.Exec(oMngsvrc & " stop")
Do While oExec.Status = 0
WshShell.Run oCjsleep & " 1", 0, True
Loop
If oExec.ExitCode <> 0 Then
Resource.LogInformation "### Management Server cannot stop. ### rtn=" & oExec.ExitCode
Resource.LogInformation oExec.StdOut.ReadAll
End If
Offline = True
End Function
' ==== Close ====
Function Close( )
Resource.LogInformation "======== Entering Close. ========"
End Function
' ==== Terminate ====
Function Terminate( )
Resource.LogInformation "======== Entering Terminate. ========"
End Function |