Skip to content
This repository has been archived by the owner on Dec 2, 2023. It is now read-only.

Commit

Permalink
(fix): debug docker redis
Browse files Browse the repository at this point in the history
  • Loading branch information
adwpc committed Nov 8, 2021
1 parent 5ed26f4 commit aa41932
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions apps/room/server/room.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ func (r *RoomServer) StartGRPC(registrar grpc.ServiceRegistrar) error {
r.natsDiscoveryCli = ndc
r.natsConn = nil
r.RoomService = *NewRoomService(r.conf.Redis)
log.Infof("NewRoomService r.conf.Redis=%+v r.redis=%+v", r.conf.Redis, r.redis)
r.RoomSignalService = *NewRoomSignalService(&r.RoomService)

room.RegisterRoomServiceServer(registrar, &r.RoomService)
Expand Down Expand Up @@ -171,6 +172,7 @@ func (r *RoomServer) Start() error {
r.natsDiscoveryCli = ndc
r.natsConn = r.NatsConn()
r.RoomService = *NewRoomService(r.conf.Redis)
log.Infof("NewRoomService r.conf.Redis=%+v r.redis=%+v", r.conf.Redis, r.redis)
r.RoomSignalService = *NewRoomSignalService(&r.RoomService)

if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion apps/room/server/room_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ func (s *RoomService) UpdatePeer(ctx context.Context, in *room.UpdatePeerRequest
}

// check peer exist
log.Infof("sid=%v uid=v", sid, uid)
log.Infof("sid=%v uid=%v", sid, uid)
key = util.GetRedisPeerKey(sid, uid)
if s.redis.HGet(key, "uid") == "" {
return &room.UpdatePeerReply{
Expand Down
4 changes: 4 additions & 0 deletions configs/docker/app-room.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ level = "info"
[nats]
url = "nats://nats:4222"

[redis]
addrs = ["redis:6379"]
password = ""
db = 0
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ services:
- "./configs/docker/app-room.toml:/configs/app-room.toml"
depends_on:
- nats
- redis
- islb
networks:
- ionnet
Expand Down
3 changes: 3 additions & 0 deletions pkg/db/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type Redis struct {

func NewRedis(c Config) *Redis {
if len(c.Addrs) == 0 {
log.Errorf("invalid addrs: %v", c.Addrs)
return nil
}

Expand All @@ -48,6 +49,7 @@ func NewRedis(c Config) *Redis {
}
r.single.Do("CONFIG", "SET", "notify-keyspace-events", "AKE")
r.clusterMode = false
log.Infof("redis new client single mode: %v", r)
return r
}

Expand All @@ -64,6 +66,7 @@ func NewRedis(c Config) *Redis {
}
r.cluster.Do("CONFIG", "SET", "notify-keyspace-events", "AKE")
r.clusterMode = true
log.Infof("redis new client cluster mode: %v", r)
return r
}

Expand Down

0 comments on commit aa41932

Please sign in to comment.