Skip to content

Commit

Permalink
admin: Close admin endpoint when shutting down (fixes #3269)
Browse files Browse the repository at this point in the history
  • Loading branch information
mholt committed Apr 16, 2020
1 parent f5ccb90 commit 9a57263
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions sigtrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9a57263

Please sign in to comment.