game/server/gate/cmd/cmd.go

31 lines
549 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(version string) {
config.LoadConfig()
log.Info(fmt.Sprintf("版本信息.%v", version))
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))
}