mirror of
https://github.com/caddyserver/caddy.git
synced 2025-06-23 15:31:40 -04:00
Remove pidfile when program exits (closes #495)
This commit is contained in:
parent
dab679df86
commit
0830c728fe
@ -32,10 +32,18 @@ func trapSignalsCrossPlatform() {
|
|||||||
|
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
log.Println("[INFO] SIGINT: Force quit")
|
log.Println("[INFO] SIGINT: Force quit")
|
||||||
|
if PidFile != "" {
|
||||||
|
os.Remove(PidFile)
|
||||||
|
}
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Println("[INFO] SIGINT: Shutting down")
|
log.Println("[INFO] SIGINT: Shutting down")
|
||||||
|
|
||||||
|
if PidFile != "" {
|
||||||
|
os.Remove(PidFile)
|
||||||
|
}
|
||||||
|
|
||||||
go os.Exit(executeShutdownCallbacks("SIGINT"))
|
go os.Exit(executeShutdownCallbacks("SIGINT"))
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
@ -20,6 +20,9 @@ func trapSignalsPosix() {
|
|||||||
switch sig {
|
switch sig {
|
||||||
case syscall.SIGTERM:
|
case syscall.SIGTERM:
|
||||||
log.Println("[INFO] SIGTERM: Terminating process")
|
log.Println("[INFO] SIGTERM: Terminating process")
|
||||||
|
if PidFile != "" {
|
||||||
|
os.Remove(PidFile)
|
||||||
|
}
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
|
|
||||||
case syscall.SIGQUIT:
|
case syscall.SIGQUIT:
|
||||||
@ -30,6 +33,9 @@ func trapSignalsPosix() {
|
|||||||
log.Printf("[ERROR] SIGQUIT stop: %v", err)
|
log.Printf("[ERROR] SIGQUIT stop: %v", err)
|
||||||
exitCode = 1
|
exitCode = 1
|
||||||
}
|
}
|
||||||
|
if PidFile != "" {
|
||||||
|
os.Remove(PidFile)
|
||||||
|
}
|
||||||
os.Exit(exitCode)
|
os.Exit(exitCode)
|
||||||
|
|
||||||
case syscall.SIGHUP:
|
case syscall.SIGHUP:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user