Remove pidfile if pidfile was created (#2358)
Also, ensure pidfile perms are 644
This commit is contained in:
parent
510b750da4
commit
4816615deb
|
@ -194,14 +194,21 @@ func reloadLoop(
|
||||||
log.Printf("I! Tags enabled: %s", c.ListTags())
|
log.Printf("I! Tags enabled: %s", c.ListTags())
|
||||||
|
|
||||||
if *fPidfile != "" {
|
if *fPidfile != "" {
|
||||||
f, err := os.Create(*fPidfile)
|
f, err := os.OpenFile(*fPidfile, os.O_CREATE|os.O_WRONLY, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("E! Unable to create pidfile: %s", err)
|
log.Printf("E! Unable to create pidfile: %s", err)
|
||||||
}
|
} else {
|
||||||
|
|
||||||
fmt.Fprintf(f, "%d\n", os.Getpid())
|
fmt.Fprintf(f, "%d\n", os.Getpid())
|
||||||
|
|
||||||
f.Close()
|
f.Close()
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
err := os.Remove(*fPidfile)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("E! Unable to remove pidfile: %s", err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ag.Run(shutdown)
|
ag.Run(shutdown)
|
||||||
|
|
Loading…
Reference in New Issue