summaryrefslogtreecommitdiff
path: root/sigtrap.go
diff options
context:
space:
mode:
Diffstat (limited to 'sigtrap.go')
-rw-r--r--sigtrap.go32
1 files changed, 5 insertions, 27 deletions
diff --git a/sigtrap.go b/sigtrap.go
index 4ad94c1..0fce6d0 100644
--- a/sigtrap.go
+++ b/sigtrap.go
@@ -47,37 +47,15 @@ func trapSignalsCrossPlatform() {
}
Log().Info("shutting down", zap.String("signal", "SIGINT"))
- go gracefulStop("SIGINT")
+ go exitProcessFromSignal("SIGINT")
}
}()
}
-// 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 config",
- zap.String("signal", sigName),
- zap.Error(err))
- exitCode = ExitCodeFailedQuit
- }
-
- if adminServer != nil {
- err = stopAdminServer(adminServer)
- if err != nil {
- Log().Error("stopping admin endpoint",
- zap.String("signal", sigName),
- zap.Error(err))
- exitCode = ExitCodeFailedQuit
- }
- }
+// exitProcessFromSignal exits the process from a system signal.
+func exitProcessFromSignal(sigName string) {
+ logger := Log().With(zap.String("signal", sigName))
+ exitProcess(logger)
}
// Exit codes. Generally, you should NOT