From 1464836f05b8aaaa44add4fde85dd0f01b84232d Mon Sep 17 00:00:00 2001 From: fatedier Date: Fri, 11 May 2018 10:42:57 +0800 Subject: [PATCH] logs panic debug strace info --- client/control.go | 3 +++ models/config/proxy.go | 2 ++ server/control.go | 8 +++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/client/control.go b/client/control.go index 7c183c28..53669ae5 100644 --- a/client/control.go +++ b/client/control.go @@ -19,6 +19,7 @@ import ( "io" "io/ioutil" "runtime" + "runtime/debug" "sync" "time" @@ -271,6 +272,7 @@ func (ctl *Control) reader() { defer func() { if err := recover(); err != nil { ctl.Error("panic error: %v", err) + ctl.Error(string(debug.Stack())) } }() defer ctl.readerShutdown.Done() @@ -319,6 +321,7 @@ func (ctl *Control) msgHandler() { defer func() { if err := recover(); err != nil { ctl.Error("panic error: %v", err) + ctl.Error(string(debug.Stack())) } }() defer ctl.msgHandlerShutdown.Done() diff --git a/models/config/proxy.go b/models/config/proxy.go index e6022b68..9558f5b0 100644 --- a/models/config/proxy.go +++ b/models/config/proxy.go @@ -512,6 +512,7 @@ func (cfg *HttpProxyConf) CheckForSvr() (err error) { err = fmt.Errorf("type [http] not support when vhost_http_port is not set") } if err = cfg.DomainConf.checkForSvr(); err != nil { + err = fmt.Errorf("proxy [%s] domain conf check error: %v", cfg.ProxyName, err) return } return @@ -574,6 +575,7 @@ func (cfg *HttpsProxyConf) CheckForSvr() (err error) { return fmt.Errorf("type [https] not support when vhost_https_port is not set") } if err = cfg.DomainConf.checkForSvr(); err != nil { + err = fmt.Errorf("proxy [%s] domain conf check error: %v", cfg.ProxyName, err) return } return diff --git a/server/control.go b/server/control.go index 26a0cf12..85b84848 100644 --- a/server/control.go +++ b/server/control.go @@ -17,6 +17,7 @@ package server import ( "fmt" "io" + "runtime/debug" "sync" "time" @@ -125,6 +126,7 @@ func (ctl *Control) RegisterWorkConn(conn net.Conn) { defer func() { if err := recover(); err != nil { ctl.conn.Error("panic error: %v", err) + ctl.conn.Error(string(debug.Stack())) } }() @@ -145,6 +147,7 @@ func (ctl *Control) GetWorkConn() (workConn net.Conn, err error) { defer func() { if err := recover(); err != nil { ctl.conn.Error("panic error: %v", err) + ctl.conn.Error(string(debug.Stack())) } }() @@ -199,6 +202,7 @@ func (ctl *Control) writer() { defer func() { if err := recover(); err != nil { ctl.conn.Error("panic error: %v", err) + ctl.conn.Error(string(debug.Stack())) } }() @@ -228,6 +232,7 @@ func (ctl *Control) reader() { defer func() { if err := recover(); err != nil { ctl.conn.Error("panic error: %v", err) + ctl.conn.Error(string(debug.Stack())) } }() @@ -254,6 +259,7 @@ func (ctl *Control) stoper() { defer func() { if err := recover(); err != nil { ctl.conn.Error("panic error: %v", err) + ctl.conn.Error(string(debug.Stack())) } }() @@ -292,6 +298,7 @@ func (ctl *Control) manager() { defer func() { if err := recover(); err != nil { ctl.conn.Error("panic error: %v", err) + ctl.conn.Error(string(debug.Stack())) } }() @@ -306,7 +313,6 @@ func (ctl *Control) manager() { case <-heartbeat.C: if time.Since(ctl.lastPing) > time.Duration(g.GlbServerCfg.HeartBeatTimeout)*time.Second { ctl.conn.Warn("heartbeat timeout") - ctl.allShutdown.Start() return } case rawMsg, ok := <-ctl.readCh: