Quellcode durchsuchen

@author liuqing
@commit panic(nil) — 无诊断信息修改

lq vor 3 Monaten
Ursprung
Commit
c78b08e58a
1 geänderte Dateien mit 15 neuen und 3 gelöschten Zeilen
  1. 15 3
      cloud/ipolesvr/main.go

+ 15 - 3
cloud/ipolesvr/main.go

@@ -40,14 +40,26 @@ func DestroyMysql() {
 }
 
 func ReadConfig() bool {
-	dir, _ := os.Getwd() //filepath.Abs(filepath.Dir(os.Args[0]))
+	dir, _ := os.Getwd()
 	fPath := dir + string(filepath.Separator) + "conf" + string(filepath.Separator)
 	errA := RedisConfig.ReadConfig(fPath, "redis")
 	errB := MySQLConfig.ReadConfig(fPath, "mysql")
 	errC := MQTTConfig.ReadConfig(fPath, "broker")
 	errD := mainConfig.ReadConfig(fPath, "ipolesvr")
 	_ = MqttconfigHl.ReadConfig(fPath, "broker_highland")
-	return errA && errB && errC && errD //&& err_e
+	if !errA {
+		logrus.Error("读取redis配置失败")
+	}
+	if !errB {
+		logrus.Error("读取mysql配置失败")
+	}
+	if !errC {
+		logrus.Error("读取mqtt broker配置失败")
+	}
+	if !errD {
+		logrus.Error("读取ipolesvr配置失败")
+	}
+	return errA && errB && errC && errD
 }
 
 func main() {
@@ -67,7 +79,7 @@ func main() {
 	}()
 
 	if !ReadConfig() {
-		panic(nil)
+		logrus.Fatal("读取配置文件失败,服务退出")
 	}
 	GetMQTTMgr()
 	GetHlMqttMgr() //hl