作者 唐旭辉

更新

@@ -26,13 +26,16 @@ func main() { @@ -26,13 +26,16 @@ func main() {
26 return 26 return
27 } 27 }
28 go func() { 28 go func() {
  29 + logs.Info("应用启动")
  30 + beego.Run()
  31 + }()
  32 + for {
29 select { 33 select {
30 case <-sigs: 34 case <-sigs:
31 cancel() 35 cancel()
32 closeConsumer() 36 closeConsumer()
  37 + return
  38 + default:
  39 + }
33 } 40 }
34 - }()  
35 -  
36 - logs.Info("应用启动")  
37 - beego.Run()  
38 } 41 }
@@ -9,10 +9,10 @@ var Cfg MqConfig @@ -9,10 +9,10 @@ var Cfg MqConfig
9 9
10 func init() { 10 func init() {
11 Cfg = MqConfig{ 11 Cfg = MqConfig{
12 - Servers: []string{"192.168.190.136:9092"}, 12 + Servers: []string{"106.52.15.41:9092"},
13 ConsumerId: "partnermg", 13 ConsumerId: "partnermg",
14 } 14 }
15 } 15 }
16 16
17 -// "", 17 +// "192.168.190.136:9092",
18 // "106.52.15.41:9092" 18 // "106.52.15.41:9092"
@@ -100,7 +100,7 @@ func StartConsumer(ctx context.Context) (func(), error) { @@ -100,7 +100,7 @@ func StartConsumer(ctx context.Context) (func(), error) {
100 }() 100 }()
101 //等待 consumerGroup 设置完成 101 //等待 consumerGroup 设置完成
102 <-consumer.ready 102 <-consumer.ready
103 - logs.Error("Sarama consumer up and running!...") 103 + logs.Info("Sarama consumer up and running!...")
104 return func() { 104 return func() {
105 wg.Wait() 105 wg.Wait()
106 if err := consumerGroup.Close(); err != nil { 106 if err := consumerGroup.Close(); err != nil {