mirror of
https://github.com/caddyserver/caddy.git
synced 2025-01-16 07:46:28 +03:00
Remove pidfile when program exits (closes #495)
This commit is contained in:
parent
dab679df86
commit
0830c728fe
2 changed files with 14 additions and 0 deletions
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue