From 6ebc314bdf2bcce7dd306d360b4188d0b4a89167 Mon Sep 17 00:00:00 2001 From: Franklin Harding Date: Sun, 1 Oct 2017 01:38:34 -0700 Subject: [PATCH] Added os.TempDir() to replace using '/tmp/' to make the tempdir cross platform Signed-off-by: Franklin Harding --- watchdog/main.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/watchdog/main.go b/watchdog/main.go index 1f0ad923..5a0cb8d5 100644 --- a/watchdog/main.go +++ b/watchdog/main.go @@ -5,6 +5,7 @@ package main import ( "bytes" + "path/filepath" "fmt" "io/ioutil" "log" @@ -252,13 +253,11 @@ func main() { http.HandleFunc("/", makeRequestHandler(&config)) - if config.suppressLock == false { - path := "/tmp/.lock" - log.Printf("Writing lock-file to: %s\n", path) - writeErr := ioutil.WriteFile(path, []byte{}, 0660) - if writeErr != nil { - log.Panicf("Cannot write %s. To disable lock-file set env suppress_lock=true.\n Error: %s.\n", path, writeErr.Error()) - } + path := filepath.Join(os.TempDir(), ".lock") + log.Printf("Writing lock-file to: %s\n", path) + writeErr := ioutil.WriteFile(path, []byte{}, 0660) + if writeErr != nil { + log.Panicf("Cannot write %s. To disable lock-file set env suppress_lock=true.\n Error: %s.\n", path, writeErr.Error()) } log.Fatal(s.ListenAndServe()) }