|
|
@ -6,8 +6,6 @@ import ( |
|
|
|
"GoClouds/webs/sys/route" |
|
|
|
"GoClouds/webs/sys/routehb" |
|
|
|
"context" |
|
|
|
"errors" |
|
|
|
"fmt" |
|
|
|
hbtp "github.com/mgr9525/HyperByte-Transfer-Protocol" |
|
|
|
"github.com/mgr9525/go-cloud" |
|
|
|
"github.com/sirupsen/logrus" |
|
|
@ -28,6 +26,7 @@ func main() { |
|
|
|
println("initFuns err:" + err.Error()) |
|
|
|
os.Exit(1) |
|
|
|
} |
|
|
|
go StartConnEngine(gocloud.CloudConf.Custom.GetString("hbtpHost")) |
|
|
|
if err := gocloud.Run(); err != nil { |
|
|
|
logrus.Errorf("gocloud run err:%v", err) |
|
|
|
} |
|
|
@ -42,11 +41,6 @@ func initFuns() error { |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
hbhost := fmt.Sprintf("%v", gocloud.CloudConf.Custom["hbtpHost"]) |
|
|
|
if gocloud.CloudConf.Custom["hbtpHost"] == nil || hbhost == "" { |
|
|
|
return errors.New("hbtp bind host err") |
|
|
|
} |
|
|
|
go StartConnEngine(hbhost) |
|
|
|
gocloud.Web.Use(gocloud.MidAccessAllowFun) |
|
|
|
gocloud.RegController(&route.IndexHandler{}) |
|
|
|
/*gocloud.Web.FuncMap["MgrsHost"] = func() string { |
|
|
@ -66,6 +60,10 @@ func SyncTable() error { |
|
|
|
} |
|
|
|
|
|
|
|
func StartConnEngine(host string) { |
|
|
|
if host == "" { |
|
|
|
logrus.Error("StartConnEngine run err:host is empty") |
|
|
|
os.Exit(1) |
|
|
|
} |
|
|
|
eng := hbtp.NewEngine(context.Background()) |
|
|
|
eng.RegFun(1, hbtp.RPCFunHandle(&routehb.CommRPC{})) |
|
|
|
eng.RegFun(2, hbtp.RPCFunHandle(&routehb.UserRPC{})) |
|
|
|