Commit a1a9b2c5 authored by hujiebin's avatar hujiebin

本地不注册

parent b7ad676a
......@@ -17,6 +17,10 @@ func AppIsRelease() bool {
return GetMode() == RELEASE
}
func AppIsLocal() bool {
return GetMode() == LOCAL
}
//数据库的配置
type MysqlConfig struct {
MYSQL_HOST string
......
......@@ -504,6 +504,10 @@ const (
)
func RegisterToRedis(RedisClusterClient *redis.Client, port int, init bool) {
// 本地不注册
if appConfig.AppIsLocal() {
return
}
if RedisClusterClient == nil {
failMsg := fmt.Sprintf("RegisterToRedis fail,redisClusterNotInit,serviceName:%v", RegisterName)
_ = dingding.SendDingRobot(dingding.ROBOTWEBHOOK, failMsg, true)
......@@ -522,7 +526,7 @@ func RegisterToRedis(RedisClusterClient *redis.Client, port int, init bool) {
if err := RedisClusterClient.ZAdd(context.Background(), redisKey, &redis.Z{
Score: float64(time.Now().Unix()),
Member: ipPort,
}); err != nil {
}).Err(); err != nil {
failMsg := fmt.Sprintf("RegisterToRedis fail,redis fail,err:%v,serviceName:%v", err, RegisterName)
mylogrus.MyLog.Errorf(failMsg)
_ = dingding.SendDingRobot(dingding.ROBOTWEBHOOK, failMsg, true)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment