优化crashed日志

This commit is contained in:
arraykeys@gmail.com
2018-09-14 11:47:50 +08:00
parent 18716cb3a2
commit 7bb5bb86dc
20 changed files with 63 additions and 63 deletions

View File

@ -418,7 +418,7 @@ func initConfig() (err error) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
for {
@ -442,7 +442,7 @@ func initConfig() (err error) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
for scanner.Scan() {
@ -452,7 +452,7 @@ func initConfig() (err error) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
for scannerStdErr.Scan() {

View File

@ -137,7 +137,7 @@ func (c *Conn) start() {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
c.reader()

View File

@ -82,7 +82,7 @@ func NewMux(conn net.PacketConn, packetSize int) *Mux {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:", e, string(debug.Stack()))
}
}()
m.readerLoop()

View File

@ -56,7 +56,7 @@ func newSendBuffer(m *Mux) *sendBuffer {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:", e, string(debug.Stack()))
}
}()
b.writerLoop()

View File

@ -155,7 +155,7 @@ func (m ConcurrentMap) Iter() <-chan Tuple {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
fanIn(chans, ch)
@ -174,7 +174,7 @@ func (m ConcurrentMap) IterBuffered() <-chan Tuple {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
fanIn(chans, ch)
@ -195,7 +195,7 @@ func snapshot(m ConcurrentMap) (chans []chan Tuple) {
go func(index int, shard *ConcurrentMapShared) {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
// Foreach key, value pair.
@ -221,7 +221,7 @@ func fanIn(chans []chan Tuple, out chan Tuple) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
func(ch chan Tuple) {
@ -274,7 +274,7 @@ func (m ConcurrentMap) Keys() []string {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
// Foreach shard.
@ -284,7 +284,7 @@ func (m ConcurrentMap) Keys() []string {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
func(shard *ConcurrentMapShared) {

View File

@ -62,7 +62,7 @@ func (s *IOBinder) AliveWithServeConn(srcAddr string, inTCPConn *net.Conn) *IOBi
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
buf := make([]byte, 1)
@ -75,7 +75,7 @@ func (s *IOBinder) AliveWithServeConn(srcAddr string, inTCPConn *net.Conn) *IOBi
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
for {
@ -96,7 +96,7 @@ func (s *IOBinder) AliveWithClientConn(srcAddr string, outTCPConn *net.Conn) *IO
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
buf := make([]byte, 1)
@ -156,7 +156,7 @@ func (s *IOBinder) Run() (err error) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
defer func() {

View File

@ -36,7 +36,7 @@ func Clean(s *services.Service) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
for _ = range signalChan {

View File

@ -60,7 +60,7 @@ func (s *DNS) InitService() (err error) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
for {
@ -142,7 +142,7 @@ func (s *DNS) Start(args interface{}, log *logger.Logger) (err error) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
log.Printf("dns server on udp %s", *s.cfg.Local)

View File

@ -183,7 +183,7 @@ func (s *HTTP) InitService() (err error) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
//循环检查ssh网络连通性

View File

@ -219,7 +219,7 @@ func (s *MuxBridge) handler(inConn net.Conn) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
for {
@ -292,7 +292,7 @@ func (s *MuxBridge) callback(inConn net.Conn, serverID, key string) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
io.Copy(stream, inConn)
@ -301,7 +301,7 @@ func (s *MuxBridge) callback(inConn net.Conn, serverID, key string) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
io.Copy(inConn, stream)

View File

@ -306,7 +306,7 @@ func (s *MuxClient) UDPRevecive(key, ID string) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
s.log.Printf("udp conn %s connected", ID)
@ -336,7 +336,7 @@ func (s *MuxClient) UDPRevecive(key, ID string) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
cui.conn.SetWriteDeadline(time.Now().Add(time.Millisecond * time.Duration(*s.cfg.Timeout)))
@ -355,7 +355,7 @@ func (s *MuxClient) UDPGCDeamon() {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
if s.isStop {
@ -414,7 +414,7 @@ func (s *MuxClient) ServeConn(inConn *smux.Stream, localAddr, ID string) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
io.Copy(outConn, snappy.NewReader(inConn))
@ -423,7 +423,7 @@ func (s *MuxClient) ServeConn(inConn *smux.Stream, localAddr, ID string) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
io.Copy(snappy.NewWriter(inConn), outConn)

View File

@ -293,7 +293,7 @@ func (s *MuxServer) Start(args interface{}, log *logger.Logger) (err error) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
io.Copy(inConn, snappy.NewReader(outConn))
@ -302,7 +302,7 @@ func (s *MuxServer) Start(args interface{}, log *logger.Logger) (err error) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
io.Copy(snappy.NewWriter(outConn), inConn)
@ -397,7 +397,7 @@ func (s *MuxServer) GetConn(index string) (conn net.Conn, err error) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
for {
@ -457,7 +457,7 @@ func (s *MuxServer) UDPGCDeamon() {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
if s.isStop {
@ -536,7 +536,7 @@ func (s *MuxServer) UDPRevecive(key, ID string) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
s.log.Printf("udp conn %s connected", ID)
@ -569,7 +569,7 @@ func (s *MuxServer) UDPRevecive(key, ID string) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
s.sc.UDPListener.WriteToUDP(body, uc.srcAddr)

View File

@ -191,7 +191,7 @@ func (s *Socks) InitService() (err error) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
//循环检查ssh网络连通性

View File

@ -256,7 +256,7 @@ func (s *TCP) UDPRevecive(key string) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
s.log.Printf("udp conn %s connected", key)
@ -286,7 +286,7 @@ func (s *TCP) UDPRevecive(key string) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
(*cui.conn).SetWriteDeadline(time.Now().Add(time.Millisecond * time.Duration(*s.cfg.Timeout)))
@ -305,7 +305,7 @@ func (s *TCP) UDPGCDeamon() {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
if s.isStop {

View File

@ -159,7 +159,7 @@ func (s *TunnelClient) Start(args interface{}, log *logger.Logger) (err error) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
s.ServeUDP(localAddr, ID, serverID)
@ -168,7 +168,7 @@ func (s *TunnelClient) Start(args interface{}, log *logger.Logger) (err error) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
s.ServeConn(localAddr, ID, serverID)
@ -324,7 +324,7 @@ func (s *TunnelClient) ServeUDP(localAddr, ID, serverID string) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
(*item).udpConn.Write(body)
@ -335,7 +335,7 @@ func (s *TunnelClient) UDPRevecive(key, ID string) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
s.log.Printf("udp conn %s connected", ID)
@ -365,7 +365,7 @@ func (s *TunnelClient) UDPRevecive(key, ID string) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
(*cui.conn).SetWriteDeadline(time.Now().Add(time.Millisecond * time.Duration(*s.cfg.Timeout)))
@ -384,7 +384,7 @@ func (s *TunnelClient) UDPGCDeamon() {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
if s.isStop {

View File

@ -368,7 +368,7 @@ func (s *TunnelServer) UDPGCDeamon() {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
if s.isStop {
@ -439,7 +439,7 @@ func (s *TunnelServer) UDPRevecive(key, ID string) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
s.log.Printf("udp conn %s connected", ID)
@ -472,7 +472,7 @@ func (s *TunnelServer) UDPRevecive(key, ID string) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
s.sc.UDPListener.WriteToUDP(body, uc.srcAddr)

View File

@ -173,7 +173,7 @@ func (s *UDP) OutToUDPGCDeamon() {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
if s.isStop {
@ -215,7 +215,7 @@ func (s *UDP) OutToUDP(packet []byte, localAddr, srcAddr *net.UDPAddr) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
s.log.Printf("udp conn %s <--> %s connected", srcAddr.String(), localAddr.String())
@ -237,7 +237,7 @@ func (s *UDP) OutToUDP(packet []byte, localAddr, srcAddr *net.UDPAddr) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
(*(s.sc).UDPListener).SetWriteDeadline(time.Now().Add(time.Millisecond * time.Duration(*s.cfg.Timeout)))
@ -274,7 +274,7 @@ func (s *UDP) UDPGCDeamon() {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
if s.isStop {
@ -351,7 +351,7 @@ func (s *UDP) UDPRevecive(key string) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
s.log.Printf("udp conn %s connected", key)
@ -384,7 +384,7 @@ func (s *UDP) UDPRevecive(key string) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
s.sc.UDPListener.WriteToUDP(body, uc.srcAddr)

View File

@ -116,7 +116,7 @@ func (b *Backend) startMuxHeartCheck() {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
for {
@ -151,7 +151,7 @@ func (b *Backend) startTCPHeartCheck() {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
for {

View File

@ -155,7 +155,7 @@ func (m ConcurrentMap) Iter() <-chan Tuple {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:", e, string(debug.Stack()))
}
}()
fanIn(chans, ch)
@ -174,7 +174,7 @@ func (m ConcurrentMap) IterBuffered() <-chan Tuple {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:", e, string(debug.Stack()))
}
}()
fanIn(chans, ch)
@ -195,7 +195,7 @@ func snapshot(m ConcurrentMap) (chans []chan Tuple) {
go func(index int, shard *ConcurrentMapShared) {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:", e, string(debug.Stack()))
}
}()
// Foreach key, value pair.
@ -221,7 +221,7 @@ func fanIn(chans []chan Tuple, out chan Tuple) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:", e, string(debug.Stack()))
}
}()
func(ch chan Tuple) {
@ -274,7 +274,7 @@ func (m ConcurrentMap) Keys() []string {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:", e, string(debug.Stack()))
}
}()
// Foreach shard.
@ -284,7 +284,7 @@ func (m ConcurrentMap) Keys() []string {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:", e, string(debug.Stack()))
}
}()
func(shard *ConcurrentMapShared) {

View File

@ -90,7 +90,7 @@ func (c *Checker) start() {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
//log.Printf("checker started")
@ -100,7 +100,7 @@ func (c *Checker) start() {
go func(item CheckerItem) {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
if c.isNeedCheck(item) {