From 534974025fa2d6c2afe583070df79c9dd0e1d4c2 Mon Sep 17 00:00:00 2001 From: liuxiaolong <liuxiaolong@aiotlink.com> Date: 星期五, 25 十二月 2020 16:02:19 +0800 Subject: [PATCH] add quit Signal --- hbusc.go | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/hbusc.go b/hbusc.go index 58a4fc7..68c2753 100644 --- a/hbusc.go +++ b/hbusc.go @@ -6,6 +6,7 @@ "encoding/json" "errors" "fmt" + "os" "strconv" "sync" "time" @@ -80,7 +81,7 @@ } //Register -func Register(ctx context.Context, config *Config, ri *RegisterInfo) (*BHBus,error) { +func Register(ctx context.Context, q chan os.Signal, config *Config, ri *RegisterInfo) (*BHBus,error) { handle := &BHBus{ conf: config, m: make(map[string]*sockServer), @@ -113,7 +114,7 @@ loop: for { select { - case <-ctx.Done(): + case <-q: return handle,errors.New("ctx is done") default: if msg == nil { -- Gitblit v1.8.0