Write termination message
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
© Copyright IBM Corporation 2017
|
||||
© Copyright IBM Corporation 2017, 2018
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -18,6 +18,7 @@ limitations under the License.
|
||||
package command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"syscall"
|
||||
@@ -38,7 +39,7 @@ func Run(name string, arg ...string) (string, int, error) {
|
||||
if ok && runtime.GOOS == "linux" {
|
||||
status, ok := exiterr.Sys().(syscall.WaitStatus)
|
||||
if ok {
|
||||
return string(out), status.ExitStatus(), err
|
||||
return string(out), status.ExitStatus(), fmt.Errorf("%v: %v", name, err)
|
||||
}
|
||||
}
|
||||
return string(out), -1, err
|
||||
|
||||
@@ -17,10 +17,10 @@ package mqini
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/ibm-messaging/mq-container/internal/command"
|
||||
)
|
||||
|
||||
// QueueManager describe high-level configuration information for a queue manager
|
||||
@@ -33,8 +33,8 @@ type QueueManager struct {
|
||||
}
|
||||
|
||||
// getQueueManagerFromStanza parses a queue manager stanza
|
||||
func getQueueManagerFromStanza(stanza []byte) (*QueueManager, error) {
|
||||
scanner := bufio.NewScanner(bytes.NewReader(stanza))
|
||||
func getQueueManagerFromStanza(stanza string) (*QueueManager, error) {
|
||||
scanner := bufio.NewScanner(strings.NewReader(stanza))
|
||||
qm := QueueManager{}
|
||||
for scanner.Scan() {
|
||||
l := scanner.Text()
|
||||
@@ -59,9 +59,7 @@ func getQueueManagerFromStanza(stanza []byte) (*QueueManager, error) {
|
||||
// GetQueueManager returns queue manager configuration information
|
||||
func GetQueueManager(name string) (*QueueManager, error) {
|
||||
// dspmqinf essentially returns a subset of mqs.ini, but it's simpler to parse
|
||||
cmd := exec.Command("dspmqinf", "-o", "stanza", name)
|
||||
// Run the command and wait for completion
|
||||
out, err := cmd.CombinedOutput()
|
||||
out, _, err := command.Run("dspmqinf", "-o", "stanza", name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ func TestGetQueueManager(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
qm, err := getQueueManagerFromStanza(b)
|
||||
qm, err := getQueueManagerFromStanza(string(b))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user