mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-16 21:56:40 -05:00
admin: Close admin endpoint when shutting down (fixes #3269)
This commit is contained in:
parent
f5ccb904a3
commit
9a572635f5
1 changed files with 14 additions and 5 deletions
19
sigtrap.go
19
sigtrap.go
|
@ -53,20 +53,29 @@ func trapSignalsCrossPlatform() {
|
|||
}
|
||||
|
||||
// gracefulStop exits the process as gracefully as possible.
|
||||
// It always exits, even if there are errors shutting down.
|
||||
func gracefulStop(sigName string) {
|
||||
exitCode := ExitCodeSuccess
|
||||
defer func() {
|
||||
Log().Info("shutdown done", zap.String("signal", sigName))
|
||||
os.Exit(exitCode)
|
||||
}()
|
||||
|
||||
err := stopAndCleanup()
|
||||
if err != nil {
|
||||
Log().Error("stopping",
|
||||
Log().Error("stopping config",
|
||||
zap.String("signal", sigName),
|
||||
zap.Error(err),
|
||||
)
|
||||
zap.Error(err))
|
||||
exitCode = ExitCodeFailedQuit
|
||||
}
|
||||
|
||||
Log().Info("shutdown done", zap.String("signal", sigName))
|
||||
os.Exit(exitCode)
|
||||
err = stopAdminServer(adminServer)
|
||||
if err != nil {
|
||||
Log().Error("stopping admin endpoint",
|
||||
zap.String("signal", sigName),
|
||||
zap.Error(err))
|
||||
exitCode = ExitCodeFailedQuit
|
||||
}
|
||||
}
|
||||
|
||||
// Exit codes. Generally, you should NOT
|
||||
|
|
Loading…
Reference in a new issue