修复bug

This commit is contained in:
liuxiaobo 2025-06-15 11:25:51 +08:00
parent fd951aa62f
commit 19714535b5
4 changed files with 42 additions and 38 deletions

View File

@ -30,7 +30,7 @@ func RpcGetGameUser(bindService *userBindService.UserBindService, s service.ISer
UID: uid,
},
}
rpcMsg := ipb.MakeRpcMsg[user.GameUser](GetGameUser, uid, us)
rpcMsg := ipb.MakeRpcMsg(GetGameUser, uid, us)
rspMsg, err := s.Call(service.RpcTopicEx(node.Name), timeout, rpcMsg)
if err != nil {
log.ErrorF("call rpc:%v err:%s ", rpcMsg.RpcMsgId, err.Error())

View File

@ -1,22 +1,16 @@
package config
import (
"context"
"encoding/json"
"errors"
"fmt"
"game/common/config"
"game/common/constant"
"github.com/fox/fox/db"
"github.com/fox/fox/log"
"github.com/go-redis/redis/v8"
)
var Command *config.Command
var Cfg *config.Common[MatchConfig]
var Cfg *config.Common
type MatchConfig struct {
//Color *game.ColorConfig
}
func InitLog() {
@ -35,7 +29,7 @@ func LoadConfig(GitCommit, GitBranch, BuildDate string) {
return
}
defer func() { _ = rdb.Close() }()
Cfg, err = config.LoadCommonConfig[MatchConfig](rdb, GitCommit, GitBranch, BuildDate)
Cfg, err = config.LoadCommonConfig(rdb, GitCommit, GitBranch, BuildDate)
if err != nil {
log.Error(err.Error())
return
@ -44,28 +38,3 @@ func LoadConfig(GitCommit, GitBranch, BuildDate string) {
//Cfg.Special.Color, err = LoadGameConfig[game.ColorConfig](rdb, game.ColorKey)
}
type Value[T any] struct {
Val T
}
func LoadGameConfig[T any](rd *redis.Client, gameKey string) (*T, error) {
s, err := rd.Get(context.Background(), gameKey).Result()
if err != nil && !errors.Is(err, redis.Nil) {
log.ErrorF("init config:%v", err)
return nil, err
}
if s == "" {
return nil, fmt.Errorf("config:%s not found from redis", gameKey)
}
var val Value[T]
if err = json.Unmarshal([]byte(s), &val.Val); err != nil {
log.ErrorF("init %v config:%v", gameKey, err)
return nil, err
}
return &val.Val, nil
}
//func GetColorConfig() *game.ColorConfig {
// return Cfg.Special.Color
//}

View File

@ -3,15 +3,14 @@ package server
import (
"game/common/proto/pb"
"github.com/fox/fox/processor"
"time"
)
const (
timeout = time.Second * 30
// timeout = time.Second * 30
)
func (s *MatchService) initProcessor() {
s.processor.RegisterMessages(processor.RegisterMetas{
pb.MsgId_C2SMatchRoomId: {pb.C2SMatchRoom{}, s.onMatchRoom},
pb.MsgId_ReqMatchRoomId: {pb.ReqMatchRoom{}, s.onMatchRoom},
})
}

View File

@ -1,6 +1,33 @@
; /etc/supervisor/conf.d/your_program.conf
[program:colorgame]
command=/home/ubuntu/game/colorgame -redis_host="114.132.124.145" -redis_port="6379" -redis_password="fox379@@zyxi" -sid=1 -num=1 -v_mod="dev" ; 完整命令参数
directory=/home/ubuntu/game ; 程序工作目录
user=ubuntu ; 运行用户
autostart=true ; 随 Supervisor 启动
autorestart=false ; 自动重启
startsecs=10 ; 启动等待时间
startretries=3 ; 启动重试次数
[program:lobby]
command=/home/ubuntu/game/lobby -redis_host="114.132.124.145" -redis_port="6379" -redis_password="fox379@@zyxi" -sid=1 -num=1 -v_mod="dev" ; 完整命令参数
directory=/home/ubuntu/game ; 程序工作目录
user=ubuntu ; 运行用户
autostart=true ; 随 Supervisor 启动
autorestart=false ; 自动重启
startsecs=10 ; 启动等待时间
startretries=3 ; 启动重试次数
[program:match]
command=/home/ubuntu/game/match -redis_host="114.132.124.145" -redis_port="6379" -redis_password="fox379@@zyxi" -sid=1 -num=1 -v_mod="dev" ; 完整命令参数
directory=/home/ubuntu/game ; 程序工作目录
user=ubuntu ; 运行用户
autostart=true ; 随 Supervisor 启动
autorestart=false ; 自动重启
startsecs=10 ; 启动等待时间
startretries=3 ; 启动重试次数
[program:gate]
command=/home/ubuntu/game/gate -redis_host="114.132.124.145" -redis_port="6379" -redis_password="fox379@@zyxi" -sid=1 -num=1 -v_mod="dev" ; 完整命令参数
command=/home/ubuntu/game/gate -redis_host="114.132.124.145" -redis_port="6379" -redis_password="fox379@@zyxi" -sid=1 -num=2 -v_mod="dev" ; 完整命令参数
directory=/home/ubuntu/game ; 程序工作目录
user=ubuntu ; 运行用户
autostart=true ; 随 Supervisor 启动
@ -26,6 +53,15 @@ autorestart=false ; 自动重启
startsecs=10 ; 启动等待时间
startretries=3 ; 启动重试次数
[program:db]
command=/home/ubuntu/game/db -redis_host="114.132.124.145" -redis_port="6379" -redis_password="fox379@@zyxi" -sid=1 -num=10 -v_mod="dev" ; 完整命令参数
directory=/home/ubuntu/game ; 程序工作目录
user=ubuntu ; 运行用户
autostart=true ; 随 Supervisor 启动
autorestart=false ; 自动重启
startsecs=10 ; 启动等待时间
startretries=3 ; 启动重试次数
[program:client]
command=/home/ubuntu/game/client -redis_host="114.132.124.145" -redis_port="6379" -redis_password="fox379@@zyxi" -sid=1 -num=1000 -v_mod="dev" ; 完整命令参数
directory=/home/ubuntu/game ; 程序工作目录