Ensure PID directory tree exists

pull/1378/head
Philip O'Toole 2015-01-26 18:33:06 -08:00
parent 5b5dd896bd
commit 2aa9b6ea33
1 changed files with 6 additions and 0 deletions

View File

@ -126,6 +126,12 @@ func writePIDFile(path string) {
return
}
// Ensure the required directory structure exists.
err := os.MkdirAll(filepath.Dir(path), 0700)
if err != nil {
log.Fatal(err)
}
// Retrieve the PID and write it.
pid := strconv.Itoa(os.Getpid())
if err := ioutil.WriteFile(path, []byte(pid), 0644); err != nil {