From b9e57591bff5d65e0cd4f36b67bc072e0564af2f Mon Sep 17 00:00:00 2001 From: Corey Hulen Date: Wed, 24 May 2017 07:55:52 -0700 Subject: Writing message to our logs when system panics and recovers (#6458) --- app/server.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'app/server.go') diff --git a/app/server.go b/app/server.go index a757e184e..0b45de092 100644 --- a/app/server.go +++ b/app/server.go @@ -13,13 +13,14 @@ import ( l4g "github.com/alecthomas/log4go" "github.com/gorilla/handlers" "github.com/gorilla/mux" - "github.com/mattermost/platform/model" - "github.com/mattermost/platform/store" - "github.com/mattermost/platform/utils" "github.com/rsc/letsencrypt" "github.com/tylerb/graceful" "gopkg.in/throttled/throttled.v2" "gopkg.in/throttled/throttled.v2/store/memstore" + + "github.com/mattermost/platform/model" + "github.com/mattermost/platform/store" + "github.com/mattermost/platform/utils" ) type Server struct { @@ -38,6 +39,14 @@ var allowedMethods []string = []string{ "DELETE", } +type RecoveryLogger struct { +} + +func (rl *RecoveryLogger) Println(i ...interface{}) { + l4g.Error("Please check the std error output for the stack trace") + l4g.Error(i) +} + type CorsWrapper struct { router *mux.Router } @@ -158,7 +167,7 @@ func StartServer() { Timeout: TIME_TO_WAIT_FOR_CONNECTIONS_TO_CLOSE_ON_SERVER_SHUTDOWN, Server: &http.Server{ Addr: utils.Cfg.ServiceSettings.ListenAddress, - Handler: handlers.RecoveryHandler(handlers.PrintRecoveryStack(true))(handler), + Handler: handlers.RecoveryHandler(handlers.RecoveryLogger(&RecoveryLogger{}), handlers.PrintRecoveryStack(true))(handler), ReadTimeout: time.Duration(*utils.Cfg.ServiceSettings.ReadTimeout) * time.Second, WriteTimeout: time.Duration(*utils.Cfg.ServiceSettings.WriteTimeout) * time.Second, }, -- cgit v1.2.3-1-g7c22