diff --git a/cmd/runmqserver/main.go b/cmd/runmqserver/main.go index 4ae0ac2..cbfb4e8 100644 --- a/cmd/runmqserver/main.go +++ b/cmd/runmqserver/main.go @@ -58,7 +58,11 @@ func doMain() error { // Start signal handler signalControl := signalHandler(name) - logConfig() + err = logConfig() + if err != nil { + logTermination(err) + return err + } err = createVolume("/mnt/mqm") if err != nil { logTermination(err) diff --git a/cmd/runmqserver/mqconfig.go b/cmd/runmqserver/mqconfig.go index b0d6cec..a1a2d55 100644 --- a/cmd/runmqserver/mqconfig.go +++ b/cmd/runmqserver/mqconfig.go @@ -16,6 +16,7 @@ limitations under the License. package main import ( + "fmt" "io/ioutil" "os/user" "runtime" @@ -90,12 +91,12 @@ func readMounts() error { if !detected { log.Print("No volume detected. Persistent messages may be lost") } else { - checkFS("/mnt/mqm") + return checkFS("/mnt/mqm") } return nil } -func logConfig() { +func logConfig() error { log.Printf("CPU architecture: %v", runtime.GOARCH) if runtime.GOOS == "linux" { var err error @@ -114,8 +115,12 @@ func logConfig() { } logUser() logCapabilities() - readMounts() + err = readMounts() + if err != nil { + return err + } } else { - log.Fatalf("Unsupported platform: %v", runtime.GOOS) + return fmt.Errorf("Unsupported platform: %v", runtime.GOOS) } + return nil } diff --git a/cmd/runmqserver/mqconfig_linux.go b/cmd/runmqserver/mqconfig_linux.go index 8371395..d0ec357 100644 --- a/cmd/runmqserver/mqconfig_linux.go +++ b/cmd/runmqserver/mqconfig_linux.go @@ -18,6 +18,7 @@ limitations under the License. package main import ( + "fmt" "golang.org/x/sys/unix" ) @@ -33,18 +34,19 @@ var fsTypes = map[int64]string{ 0x794c7630: "overlayfs", } -func checkFS(path string) { +func checkFS(path string) error { statfs := &unix.Statfs_t{} err := unix.Statfs(path, statfs) if err != nil { log.Println(err) - return + return nil } t := fsTypes[statfs.Type] switch t { case "aufs", "overlayfs", "tmpfs": - log.Fatalf("Error: %v uses unsupported filesystem type %v", path, t) + return fmt.Errorf("%v uses unsupported filesystem type: %v", path, t) default: log.Printf("Detected %v has filesystem type '%v'", path, t) + return nil } } diff --git a/cmd/runmqserver/mqconfig_other.go b/cmd/runmqserver/mqconfig_other.go index bb6e897..0c4c233 100644 --- a/cmd/runmqserver/mqconfig_other.go +++ b/cmd/runmqserver/mqconfig_other.go @@ -19,6 +19,6 @@ package main // Dummy version of this function, only for non-Linux systems. // Having this allows unit tests to be run on other platforms (e.g. macOS) -func checkFS(path string) { - return +func checkFS(path string) error { + return nil }