Remove log.Fatal() calls and bubble up errors
This commit is contained in:
@@ -58,7 +58,11 @@ func doMain() error {
|
|||||||
// Start signal handler
|
// Start signal handler
|
||||||
signalControl := signalHandler(name)
|
signalControl := signalHandler(name)
|
||||||
|
|
||||||
logConfig()
|
err = logConfig()
|
||||||
|
if err != nil {
|
||||||
|
logTermination(err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
err = createVolume("/mnt/mqm")
|
err = createVolume("/mnt/mqm")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logTermination(err)
|
logTermination(err)
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ limitations under the License.
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os/user"
|
"os/user"
|
||||||
"runtime"
|
"runtime"
|
||||||
@@ -90,12 +92,12 @@ func readMounts() error {
|
|||||||
if !detected {
|
if !detected {
|
||||||
log.Print("No volume detected. Persistent messages may be lost")
|
log.Print("No volume detected. Persistent messages may be lost")
|
||||||
} else {
|
} else {
|
||||||
checkFS("/mnt/mqm")
|
return checkFS("/mnt/mqm")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func logConfig() {
|
func logConfig() error {
|
||||||
log.Printf("CPU architecture: %v", runtime.GOARCH)
|
log.Printf("CPU architecture: %v", runtime.GOARCH)
|
||||||
if runtime.GOOS == "linux" {
|
if runtime.GOOS == "linux" {
|
||||||
var err error
|
var err error
|
||||||
@@ -114,8 +116,12 @@ func logConfig() {
|
|||||||
}
|
}
|
||||||
logUser()
|
logUser()
|
||||||
logCapabilities()
|
logCapabilities()
|
||||||
readMounts()
|
err = readMounts()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
log.Fatalf("Unsupported platform: %v", runtime.GOOS)
|
return errors.New(fmt.Sprintf("Unsupported platform: %v", runtime.GOOS))
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ limitations under the License.
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -33,18 +35,19 @@ var fsTypes = map[int64]string{
|
|||||||
0x794c7630: "overlayfs",
|
0x794c7630: "overlayfs",
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkFS(path string) {
|
func checkFS(path string) error {
|
||||||
statfs := &unix.Statfs_t{}
|
statfs := &unix.Statfs_t{}
|
||||||
err := unix.Statfs(path, statfs)
|
err := unix.Statfs(path, statfs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
return
|
return nil
|
||||||
}
|
}
|
||||||
t := fsTypes[statfs.Type]
|
t := fsTypes[statfs.Type]
|
||||||
switch t {
|
switch t {
|
||||||
case "aufs", "overlayfs", "tmpfs":
|
case "aufs", "overlayfs", "tmpfs":
|
||||||
log.Fatalf("Error: %v uses unsupported filesystem type %v", path, t)
|
return errors.New(fmt.Sprintf("Error: %v uses unsupported filesystem type %v", path, t))
|
||||||
default:
|
default:
|
||||||
log.Printf("Detected %v has filesystem type '%v'", path, t)
|
log.Printf("Detected %v has filesystem type '%v'", path, t)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,6 @@ package main
|
|||||||
|
|
||||||
// Dummy version of this function, only for non-Linux systems.
|
// Dummy version of this function, only for non-Linux systems.
|
||||||
// Having this allows unit tests to be run on other platforms (e.g. macOS)
|
// Having this allows unit tests to be run on other platforms (e.g. macOS)
|
||||||
func checkFS(path string) {
|
func checkFS(path string) error {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user