Skip to content

Commit

Permalink
bug fix: 捕获panic,防止程序停止运行
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason committed Aug 2, 2023
1 parent 7bd379a commit 744dcd1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion client/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (a *App) Start() {
defer func() {
a.close(conn, readTicker, latencyTicker)
// if not interrupt,restart the client
if !isInterrupt {
if r := recover(); r != nil || !isInterrupt {
time.Sleep(5 * time.Second)
a.Start()
}
Expand Down Expand Up @@ -112,6 +112,12 @@ func (a *App) Start() {
}

func (a *App) readLoop(conn *connutil.ConnWrapper) {
defer func() {
if r := recover(); r != nil {
return
}
}()

for {
blob := json.RawMessage{}
if err := conn.ReadJSON(&blob); err != nil {
Expand Down

0 comments on commit 744dcd1

Please sign in to comment.