Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
4b17a9b54c
@ -5,6 +5,7 @@ import (
|
|||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
|
"go_dreamfactory/lego"
|
||||||
"go_dreamfactory/lego/core"
|
"go_dreamfactory/lego/core"
|
||||||
"go_dreamfactory/lego/sys/log"
|
"go_dreamfactory/lego/sys/log"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@ -33,6 +34,7 @@ var confCmd = &cobra.Command{
|
|||||||
Use: "conf",
|
Use: "conf",
|
||||||
Short: "生成配置",
|
Short: "生成配置",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
lego.Recover("conf")
|
||||||
conf()
|
conf()
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -40,6 +42,7 @@ var startCmd = &cobra.Command{
|
|||||||
Use: "start",
|
Use: "start",
|
||||||
Short: "启动程序",
|
Short: "启动程序",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
lego.Recover("start")
|
||||||
start()
|
start()
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -47,6 +50,7 @@ var stopCmd = &cobra.Command{
|
|||||||
Use: "stop",
|
Use: "stop",
|
||||||
Short: "关闭程序",
|
Short: "关闭程序",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
lego.Recover("stop")
|
||||||
stop()
|
stop()
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -54,6 +58,7 @@ var restart = &cobra.Command{
|
|||||||
Use: "restart",
|
Use: "restart",
|
||||||
Short: "重启服务",
|
Short: "重启服务",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
lego.Recover("restart")
|
||||||
stop()
|
stop()
|
||||||
start()
|
start()
|
||||||
},
|
},
|
||||||
@ -92,7 +97,7 @@ func main() {
|
|||||||
//执行命令
|
//执行命令
|
||||||
func Execute() {
|
func Execute() {
|
||||||
if err := RootCmd.Execute(); err != nil {
|
if err := RootCmd.Execute(); err != nil {
|
||||||
fmt.Fprintln(os.Stdin, err)
|
log.Errorln(err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -115,6 +120,7 @@ func conf() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
log.Errorf("conf succ!")
|
||||||
}
|
}
|
||||||
|
|
||||||
//启动程序
|
//启动程序
|
||||||
@ -179,6 +185,7 @@ func start() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
log.Errorf("start succ!")
|
||||||
}
|
}
|
||||||
|
|
||||||
//关闭程序
|
//关闭程序
|
||||||
@ -197,6 +204,7 @@ func stop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
log.Errorf("stop succ!")
|
||||||
}
|
}
|
||||||
|
|
||||||
///转换区服配置到服务配置
|
///转换区服配置到服务配置
|
||||||
@ -211,7 +219,7 @@ func rederServiceSttings(config *comm.GameConfig) (ss []*core.ServiceSttings, er
|
|||||||
if ip, port, err = parseaddr(config.Mainte); err != nil {
|
if ip, port, err = parseaddr(config.Mainte); err != nil {
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
if sseting, err = convertServiceSttings(config, 0, comm.Service_Mainte, ip, config.MaintePort, port); err != nil {
|
if sseting, err = convertServiceSttings(config, 0, comm.Service_Mainte, ip, config.MaintePort, port, config.OpenServiceTime); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ss = append(ss, sseting)
|
ss = append(ss, sseting)
|
||||||
@ -221,7 +229,7 @@ func rederServiceSttings(config *comm.GameConfig) (ss []*core.ServiceSttings, er
|
|||||||
if ip, port, err = parseaddr(v); err != nil {
|
if ip, port, err = parseaddr(v); err != nil {
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
if sseting, err = convertServiceSttings(config, i, comm.Service_Worker, ip, port, 0); err != nil {
|
if sseting, err = convertServiceSttings(config, i, comm.Service_Worker, ip, port, 0, config.OpenServiceTime); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ss = append(ss, sseting)
|
ss = append(ss, sseting)
|
||||||
@ -231,7 +239,7 @@ func rederServiceSttings(config *comm.GameConfig) (ss []*core.ServiceSttings, er
|
|||||||
if ip, port, err = parseaddr(v); err != nil {
|
if ip, port, err = parseaddr(v); err != nil {
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
if sseting, err = convertServiceSttings(config, i, comm.Service_Gateway, ip, config.GatewayPorts[i], port); err != nil {
|
if sseting, err = convertServiceSttings(config, i, comm.Service_Gateway, ip, config.GatewayPorts[i], port, config.OpenServiceTime); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ss = append(ss, sseting)
|
ss = append(ss, sseting)
|
||||||
@ -260,11 +268,12 @@ func readergmconf(path string) (config *comm.GameConfig, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//转换游戏服务配置
|
//转换游戏服务配置
|
||||||
func convertServiceSttings(config *comm.GameConfig, id int, stype string, ip string, rport int, lport int) (sseting *core.ServiceSttings, err error) {
|
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 = &core.ServiceSttings{}
|
||||||
sseting.Tag = config.AreaId
|
sseting.Tag = config.AreaId
|
||||||
sseting.Ip = ip
|
sseting.Ip = ip
|
||||||
sseting.Port = rport
|
sseting.Port = rport
|
||||||
|
sseting.Opentime = opentime
|
||||||
sseting.Modules = make(map[string]map[string]interface{})
|
sseting.Modules = make(map[string]map[string]interface{})
|
||||||
sseting.Sys = make(map[string]map[string]interface{})
|
sseting.Sys = make(map[string]map[string]interface{})
|
||||||
sseting.Sys["rpcx"] = map[string]interface{}{
|
sseting.Sys["rpcx"] = map[string]interface{}{
|
||||||
@ -306,6 +315,7 @@ func convertServiceSttings(config *comm.GameConfig, id int, stype string, ip str
|
|||||||
}
|
}
|
||||||
sseting.Sys["configure"] = map[string]interface{}{
|
sseting.Sys["configure"] = map[string]interface{}{
|
||||||
"ConfigurePath": "./json",
|
"ConfigurePath": "./json",
|
||||||
|
"TimestampFile": "./timestamp.text",
|
||||||
}
|
}
|
||||||
sseting.Sys["wordfilter"] = map[string]interface{}{
|
sseting.Sys["wordfilter"] = map[string]interface{}{
|
||||||
"WorldFile": "./wordfilter.json",
|
"WorldFile": "./wordfilter.json",
|
||||||
|
Loading…
Reference in New Issue
Block a user