game/server/gate/cmd/cmd.go

32 lines
673 B
Go
Raw Normal View History

2025-05-25 20:34:08 +08:00
package cmd
import (
"fmt"
"game/server/gate/config"
2025-05-26 20:14:17 +08:00
"game/server/gate/model"
2025-05-25 20:34:08 +08:00
"game/server/gate/server"
"github.com/fox/fox/log"
"os"
"os/signal"
"syscall"
)
func initRepo() {
2025-05-26 20:14:17 +08:00
model.InitRedis()
2025-05-25 20:34:08 +08:00
}
func Run(GitCommit, GitBranch, BuildDate string) {
2025-05-30 23:15:53 +08:00
config.InitLog()
config.LoadConfig(GitCommit, GitBranch, BuildDate)
log.Info(fmt.Sprintf("版本分支:%v,hash值:%v,编译时间:%v", GitBranch, GitCommit, BuildDate))
2025-05-26 20:14:17 +08:00
initRepo()
2025-05-25 20:34:08 +08:00
server.Init()
// 截获 SIGINT 和 SIGTERM 信号
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGINT, syscall.SIGTERM)
sig := <-c
2025-05-25 20:50:56 +08:00
server.Stop()
2025-05-25 20:34:08 +08:00
log.Info(fmt.Sprintf("received %s, initiating shutdown...", sig))
}