Update ready check for native-HA

This commit is contained in:
Stephen Marshall
2020-12-07 20:04:59 +00:00
parent adf15b7bd3
commit 68fe4a1dc1
2 changed files with 12 additions and 2 deletions

View File

@@ -39,7 +39,7 @@ func main() {
} }
// Check if the queue manager has a running listener // Check if the queue manager has a running listener
if standby, _ := ready.IsRunningAsStandbyQM(name); !standby { if active, _ := ready.IsRunningAsActiveQM(name); active {
conn, err := net.Dial("tcp", "127.0.0.1:1414") conn, err := net.Dial("tcp", "127.0.0.1:1414")
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
@@ -49,8 +49,13 @@ func main() {
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
} }
} else { } else if standby, _ := ready.IsRunningAsStandbyQM(name); standby {
fmt.Printf("Detected queue manager running in standby mode") fmt.Printf("Detected queue manager running in standby mode")
os.Exit(10) os.Exit(10)
} else if replica, _ := ready.IsRunningAsReplicaQM(name); replica {
fmt.Printf("Detected queue manager running in replica mode")
os.Exit(20)
} else {
os.Exit(1)
} }
} }

View File

@@ -76,6 +76,11 @@ func IsRunningAsStandbyQM(name string) (bool, error) {
return isRunningQM(name, "(RUNNING AS STANDBY)") return isRunningQM(name, "(RUNNING AS STANDBY)")
} }
// IsRunningAsReplicaQM returns true if the queue manager is running in replica mode
func IsRunningAsReplicaQM(name string) (bool, error) {
return isRunningQM(name, "(REPLICA)")
}
func isRunningQM(name string, status string) (bool, error) { func isRunningQM(name string, status string) (bool, error) {
out, _, err := command.Run("dspmq", "-n", "-m", name) out, _, err := command.Run("dspmq", "-n", "-m", name)
if err != nil { if err != nil {