You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

60 lines
1.4 KiB

  1. package config
  2. import (
  3. "context"
  4. "egg_im/pkg/k8sutil"
  5. "egg_im/pkg/logger"
  6. "go.uber.org/zap"
  7. metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
  8. "os"
  9. "strconv"
  10. )
  11. const (
  12. //RPCListenAddr = ":8000"
  13. //TCPListenAddr = ":8080"
  14. //WSListenAddr = ":8001"
  15. RPCListenAddr = ":8000"
  16. TCPListenAddr = ":8001"
  17. WSListenAddr = ":8002"
  18. )
  19. var (
  20. NameSpace string = "egg-im"
  21. MySQL string = "root:Fnuo123com@@tcp(119.23.182.117:3306)/egg_im?charset=utf8&parseTime=true&loc=Local"
  22. RedisIP string = "120.24.28.6:32572"
  23. RedisPassword string = ""
  24. LocalAddr string
  25. PushRoomSubscribeNum int
  26. PushAllSubscribeNum int
  27. )
  28. func Init() {
  29. k8sClient, err := k8sutil.GetK8sClient()
  30. if err != nil {
  31. panic(err)
  32. }
  33. configmap, err := k8sClient.CoreV1().ConfigMaps(NameSpace).Get(context.TODO(), "config", metav1.GetOptions{})
  34. if err != nil {
  35. panic(err)
  36. }
  37. MySQL = configmap.Data["mysql"]
  38. RedisIP = configmap.Data["redisIP"]
  39. RedisPassword = configmap.Data["redisPassword"]
  40. PushRoomSubscribeNum, _ = strconv.Atoi(configmap.Data["pushRoomSubscribeNum"])
  41. if PushRoomSubscribeNum == 0 {
  42. panic("PushRoomSubscribeNum == 0")
  43. }
  44. PushAllSubscribeNum, _ = strconv.Atoi(configmap.Data["pushAllSubscribeNum"])
  45. if PushRoomSubscribeNum == 0 {
  46. panic("PushAllSubscribeNum == 0")
  47. }
  48. LocalAddr = os.Getenv("POD_IP") + RPCListenAddr
  49. logger.Level = zap.DebugLevel
  50. logger.Target = logger.Console
  51. }