diff --git a/sigtrap_posix.go b/sigtrap_posix.go index 2a0a0de57..cc65ccb46 100644 --- a/sigtrap_posix.go +++ b/sigtrap_posix.go @@ -41,14 +41,14 @@ func trapSignalsPosix() { case syscall.SIGTERM: log.Println("[INFO] SIGTERM: Shutting down servers then terminating") exitCode := executeShutdownCallbacks("SIGTERM") + for _, f := range OnProcessExit { + f() // only perform important cleanup actions + } err := Stop() if err != nil { log.Printf("[ERROR] SIGTERM stop: %v", err) exitCode = 3 } - for _, f := range OnProcessExit { - f() // only perform important cleanup actions - } os.Exit(exitCode) case syscall.SIGUSR1: