From 19714535b58be7448d4016200ec7baeec5e7703c Mon Sep 17 00:00:00 2001 From: liuxiaobo <1224730913@qq.com> Date: Sun, 15 Jun 2025 11:25:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/rpc/rpcGameUser.go | 2 +- server/match/config/config.go | 35 ++--------------------------- server/match/server/processor.go | 5 ++--- server/supervisor.conf | 38 +++++++++++++++++++++++++++++++- 4 files changed, 42 insertions(+), 38 deletions(-) diff --git a/common/rpc/rpcGameUser.go b/common/rpc/rpcGameUser.go index c6f41f1..048ad85 100644 --- a/common/rpc/rpcGameUser.go +++ b/common/rpc/rpcGameUser.go @@ -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()) diff --git a/server/match/config/config.go b/server/match/config/config.go index 042fb3c..881bc7a 100644 --- a/server/match/config/config.go +++ b/server/match/config/config.go @@ -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 -//} diff --git a/server/match/server/processor.go b/server/match/server/processor.go index cdb4ee4..c04a3a1 100644 --- a/server/match/server/processor.go +++ b/server/match/server/processor.go @@ -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}, }) } diff --git a/server/supervisor.conf b/server/supervisor.conf index 69bc3c6..b62b24f 100644 --- a/server/supervisor.conf +++ b/server/supervisor.conf @@ -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 ; 程序工作目录