Commit 0830c728 authored by Matthew Holt's avatar Matthew Holt

Remove pidfile when program exits (closes #495)

parent dab679df
......@@ -32,10 +32,18 @@ func trapSignalsCrossPlatform() {
if i > 0 {
log.Println("[INFO] SIGINT: Force quit")
if PidFile != "" {
os.Remove(PidFile)
}
os.Exit(1)
}
log.Println("[INFO] SIGINT: Shutting down")
if PidFile != "" {
os.Remove(PidFile)
}
go os.Exit(executeShutdownCallbacks("SIGINT"))
}
}()
......
......@@ -20,6 +20,9 @@ func trapSignalsPosix() {
switch sig {
case syscall.SIGTERM:
log.Println("[INFO] SIGTERM: Terminating process")
if PidFile != "" {
os.Remove(PidFile)
}
os.Exit(0)
case syscall.SIGQUIT:
......@@ -30,6 +33,9 @@ func trapSignalsPosix() {
log.Printf("[ERROR] SIGQUIT stop: %v", err)
exitCode = 1
}
if PidFile != "" {
os.Remove(PidFile)
}
os.Exit(exitCode)
case syscall.SIGHUP:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment