|
|
@@ -1,9 +1,13 @@ |
|
|
|
package config |
|
|
|
|
|
|
|
import ( |
|
|
|
"context" |
|
|
|
"egg-im/pkg/k8sutil" |
|
|
|
"egg-im/pkg/logger" |
|
|
|
"go.uber.org/zap" |
|
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
|
|
|
"os" |
|
|
|
"strconv" |
|
|
|
) |
|
|
|
|
|
|
|
const ( |
|
|
@@ -27,26 +31,26 @@ var ( |
|
|
|
) |
|
|
|
|
|
|
|
func Init() { |
|
|
|
//k8sClient, err := k8sutil.GetK8sClient() |
|
|
|
//if err != nil { |
|
|
|
// panic(err) |
|
|
|
//} |
|
|
|
//configmap, err := k8sClient.CoreV1().ConfigMaps(NameSpace).Get(context.TODO(), "config", metav1.GetOptions{}) |
|
|
|
//if err != nil { |
|
|
|
// panic(err) |
|
|
|
//} |
|
|
|
// |
|
|
|
//MySQL = configmap.Data["mysql"] |
|
|
|
//RedisIP = configmap.Data["redisIP"] |
|
|
|
//RedisPassword = configmap.Data["redisPassword"] |
|
|
|
//PushRoomSubscribeNum, _ = strconv.Atoi(configmap.Data["pushRoomSubscribeNum"]) |
|
|
|
//if PushRoomSubscribeNum == 0 { |
|
|
|
// panic("PushRoomSubscribeNum == 0") |
|
|
|
//} |
|
|
|
//PushAllSubscribeNum, _ = strconv.Atoi(configmap.Data["pushAllSubscribeNum"]) |
|
|
|
//if PushRoomSubscribeNum == 0 { |
|
|
|
// panic("PushAllSubscribeNum == 0") |
|
|
|
//} |
|
|
|
k8sClient, err := k8sutil.GetK8sClient() |
|
|
|
if err != nil { |
|
|
|
panic(err) |
|
|
|
} |
|
|
|
configmap, err := k8sClient.CoreV1().ConfigMaps(NameSpace).Get(context.TODO(), "config", metav1.GetOptions{}) |
|
|
|
if err != nil { |
|
|
|
panic(err) |
|
|
|
} |
|
|
|
|
|
|
|
MySQL = configmap.Data["mysql"] |
|
|
|
RedisIP = configmap.Data["redisIP"] |
|
|
|
RedisPassword = configmap.Data["redisPassword"] |
|
|
|
PushRoomSubscribeNum, _ = strconv.Atoi(configmap.Data["pushRoomSubscribeNum"]) |
|
|
|
if PushRoomSubscribeNum == 0 { |
|
|
|
panic("PushRoomSubscribeNum == 0") |
|
|
|
} |
|
|
|
PushAllSubscribeNum, _ = strconv.Atoi(configmap.Data["pushAllSubscribeNum"]) |
|
|
|
if PushRoomSubscribeNum == 0 { |
|
|
|
panic("PushAllSubscribeNum == 0") |
|
|
|
} |
|
|
|
|
|
|
|
LocalAddr = os.Getenv("POD_IP") + RPCListenAddr |
|
|
|
|
|
|
|