diff options
author | Corey Hulen <corey@hulen.com> | 2017-05-24 07:55:52 -0700 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2017-05-24 10:55:52 -0400 |
commit | b9e57591bff5d65e0cd4f36b67bc072e0564af2f (patch) | |
tree | 5eecf12ea253d718bb2bfa8c0d96c3aee33182a4 /app/server.go | |
parent | 42fb1c5693ba4a6c78928d7172cfc514d4a39396 (diff) | |
download | chat-b9e57591bff5d65e0cd4f36b67bc072e0564af2f.tar.gz chat-b9e57591bff5d65e0cd4f36b67bc072e0564af2f.tar.bz2 chat-b9e57591bff5d65e0cd4f36b67bc072e0564af2f.zip |
Writing message to our logs when system panics and recovers (#6458)
Diffstat (limited to 'app/server.go')
-rw-r--r-- | app/server.go | 17 |
1 files changed, 13 insertions, 4 deletions
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, }, |