Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
b6af35fd8d
@ -22,8 +22,8 @@ import (
|
||||
)
|
||||
|
||||
/*
|
||||
服务类型:区服启动程序
|
||||
服务描述:通过读取游戏json配置,启动服务程序
|
||||
服务类型:区服启动程序
|
||||
服务描述:通过读取游戏json配置,启动服务程序
|
||||
*/
|
||||
var (
|
||||
gmpath string //服务列表下标
|
||||
@ -74,7 +74,7 @@ var RootCmd = &cobra.Command{
|
||||
Run: emptyRun,
|
||||
}
|
||||
|
||||
//初始化自定义cmd
|
||||
// 初始化自定义cmd
|
||||
func init() {
|
||||
RootCmd.PersistentFlags().StringVarP(&gmpath, "gm", "g", "./gm.json", "游戏区服配置")
|
||||
RootCmd.PersistentFlags().StringVarP(&crosspath, "cross", "c", "./cross.json", "游戏跨服配置")
|
||||
@ -97,7 +97,7 @@ func main() {
|
||||
Execute()
|
||||
}
|
||||
|
||||
//执行命令
|
||||
// 执行命令
|
||||
func Execute() {
|
||||
if err := RootCmd.Execute(); err != nil {
|
||||
log.Errorln(err)
|
||||
@ -105,7 +105,7 @@ func Execute() {
|
||||
}
|
||||
}
|
||||
|
||||
//生成配置
|
||||
// 生成配置
|
||||
func conf() {
|
||||
if config, err := readergmconf(gmpath); err != nil {
|
||||
log.Error("读取区服配置失败!", log.Field{Key: "err", Value: err.Error()})
|
||||
@ -128,7 +128,7 @@ func conf() {
|
||||
log.Debugf("conf succ!")
|
||||
}
|
||||
|
||||
//启动程序
|
||||
// 启动程序
|
||||
func start() {
|
||||
if config, err := readergmconf(gmpath); err != nil {
|
||||
log.Error("读取区服配置失败!", log.Field{Key: "err", Value: err.Error()})
|
||||
@ -202,7 +202,7 @@ func start() {
|
||||
log.Errorf("start succ!")
|
||||
}
|
||||
|
||||
//关闭程序
|
||||
// 关闭程序
|
||||
func stop() {
|
||||
if config, err := readergmconf(gmpath); err != nil {
|
||||
log.Error("读取区服配置失败!", log.Field{Key: "err", Value: err.Error()})
|
||||
@ -221,7 +221,7 @@ func stop() {
|
||||
log.Infof("stop succ!")
|
||||
}
|
||||
|
||||
///转换区服配置到服务配置
|
||||
// /转换区服配置到服务配置
|
||||
func rederServiceSttings(config *comm.GameConfig) (ss []*core.ServiceSttings, err error) {
|
||||
ss = make([]*core.ServiceSttings, 0)
|
||||
var (
|
||||
@ -262,7 +262,7 @@ func rederServiceSttings(config *comm.GameConfig) (ss []*core.ServiceSttings, er
|
||||
return
|
||||
}
|
||||
|
||||
//读取游戏配置文件
|
||||
// 读取游戏配置文件
|
||||
func readergmconf(path string) (config *comm.GameConfig, err error) {
|
||||
config = &comm.GameConfig{}
|
||||
var (
|
||||
@ -281,7 +281,7 @@ func readergmconf(path string) (config *comm.GameConfig, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
//转换游戏服务配置
|
||||
// 转换游戏服务配置
|
||||
func convertServiceSttings(config *comm.GameConfig, id int, stype string, ip string, rport int, lport int, opentime string) (sseting *core.ServiceSttings, err error) {
|
||||
sseting = &core.ServiceSttings{}
|
||||
sseting.Tag = config.AreaId
|
||||
@ -364,7 +364,7 @@ func convertServiceSttings(config *comm.GameConfig, id int, stype string, ip str
|
||||
"TimestampFile": "./timestamp.text",
|
||||
}
|
||||
sseting.Sys["wordfilter"] = map[string]interface{}{
|
||||
"WorldFile": "./wordfilter.json",
|
||||
"WorldFile": []string{"./wordfilter.json", "./wordfilter.txt"},
|
||||
}
|
||||
sseting.Sys["db"] = map[string]interface{}{
|
||||
"IsCross": config.IsCross,
|
||||
@ -380,7 +380,7 @@ func convertServiceSttings(config *comm.GameConfig, id int, stype string, ip str
|
||||
return
|
||||
}
|
||||
|
||||
//启动服务程序
|
||||
// 启动服务程序
|
||||
func startService(sseting *core.ServiceSttings) (err error) {
|
||||
var (
|
||||
cmd *exec.Cmd
|
||||
@ -411,7 +411,7 @@ func startService(sseting *core.ServiceSttings) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
//启动服务程序
|
||||
// 启动服务程序
|
||||
func stopService(sseting *core.ServiceSttings) (err error) {
|
||||
var (
|
||||
cmd *exec.Cmd
|
||||
@ -441,7 +441,7 @@ func stopService(sseting *core.ServiceSttings) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
//写入服务配置文件
|
||||
// 写入服务配置文件
|
||||
func writeServiceConfig(filename string, sseting *core.ServiceSttings) (err error) {
|
||||
var data []byte
|
||||
if err = os.MkdirAll(filepath.Dir(filename), 0755); err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user