作者 yangfu

refactor: 参数优化

- 增加MQTT_UP参数,不需要订阅数据时,关闭
@@ -126,3 +126,5 @@ spec: @@ -126,3 +126,5 @@ spec:
126 value: "47.97.5.102" 126 value: "47.97.5.102"
127 - name: MQTT_PORT 127 - name: MQTT_PORT
128 value: "6000" 128 value: "6000"
  129 + - name: MQTT_UP
  130 + value: "false"
@@ -126,3 +126,5 @@ spec: @@ -126,3 +126,5 @@ spec:
126 value: "47.97.5.102" 126 value: "47.97.5.102"
127 - name: MQTT_PORT 127 - name: MQTT_PORT
128 value: "6000" 128 value: "6000"
  129 + - name: MQTT_UP
  130 + value: "false"
@@ -29,8 +29,9 @@ func main() { @@ -29,8 +29,9 @@ func main() {
29 redis.InitRedis() 29 redis.InitRedis()
30 log.Logger.Info("server start ....") 30 log.Logger.Info("server start ....")
31 log.Logger.Debug(fmt.Sprintf("ENABLE_KAFKA_LOG:%v", constant.ENABLE_KAFKA_LOG)) 31 log.Logger.Debug(fmt.Sprintf("ENABLE_KAFKA_LOG:%v", constant.ENABLE_KAFKA_LOG))
32 - 32 + if constant.MQTT_UP {
33 go mqtt.Start(log.Logger) 33 go mqtt.Start(log.Logger)
  34 + }
34 go task.Run() 35 go task.Run()
35 cron := crontab.NewCrontabService(nil) 36 cron := crontab.NewCrontabService(nil)
36 cron.StartCrontabTask() 37 cron.StartCrontabTask()
@@ -28,10 +28,12 @@ var MQTT_HOST = "47.97.5.102" @@ -28,10 +28,12 @@ var MQTT_HOST = "47.97.5.102"
28 var MQTT_PORT = "6000" 28 var MQTT_PORT = "6000"
29 var MQTT_USER = "admin" 29 var MQTT_USER = "admin"
30 var MQTT_PASSWORD = "123456" 30 var MQTT_PASSWORD = "123456"
  31 +var MQTT_UP = true
31 32
32 func init() { 33 func init() {
33 MQTT_HOST = Configurator.DefaultString("MQTT_HOST", MQTT_HOST) 34 MQTT_HOST = Configurator.DefaultString("MQTT_HOST", MQTT_HOST)
34 MQTT_PORT = Configurator.DefaultString("MQTT_PORT", MQTT_PORT) 35 MQTT_PORT = Configurator.DefaultString("MQTT_PORT", MQTT_PORT)
35 MQTT_USER = Configurator.DefaultString("MQTT_USER", MQTT_USER) 36 MQTT_USER = Configurator.DefaultString("MQTT_USER", MQTT_USER)
36 MQTT_PASSWORD = Configurator.DefaultString("MQTT_PASSWORD", MQTT_PASSWORD) 37 MQTT_PASSWORD = Configurator.DefaultString("MQTT_PASSWORD", MQTT_PASSWORD)
  38 + MQTT_UP = Configurator.DefaultBool("MQTT_UP", MQTT_UP)
37 } 39 }