|
@@ -1,50 +1,43 @@
|
|
|
package main
|
|
|
|
|
|
import (
|
|
|
- mc "app.yhyue.com/moapp/jybase/common"
|
|
|
- "app.yhyue.com/moapp/jybase/endless"
|
|
|
- "bp.jydev.jianyu360.cn/BaseService/gateway/core/node"
|
|
|
"flag"
|
|
|
"fmt"
|
|
|
- "github.com/zeromicro/go-zero/core/conf"
|
|
|
- "github.com/zeromicro/go-zero/rest"
|
|
|
- _ "jyInfo/api/common"
|
|
|
- "jyInfo/api/internal/config"
|
|
|
+ c "jyInfo/api/common"
|
|
|
"jyInfo/api/internal/handler"
|
|
|
"jyInfo/api/internal/svc"
|
|
|
"log"
|
|
|
"os"
|
|
|
"os/signal"
|
|
|
"syscall"
|
|
|
-)
|
|
|
|
|
|
-var configFile = flag.String("f", "etc/info-api.yaml", "the config file")
|
|
|
+ mc "app.yhyue.com/moapp/jybase/common"
|
|
|
+ "app.yhyue.com/moapp/jybase/endless"
|
|
|
+ "bp.jydev.jianyu360.cn/BaseService/gateway/core/node"
|
|
|
+ "github.com/zeromicro/go-zero/rest"
|
|
|
+)
|
|
|
|
|
|
func main() {
|
|
|
-
|
|
|
flag.Parse()
|
|
|
|
|
|
- var c config.Config
|
|
|
- conf.MustLoad(*configFile, &c)
|
|
|
-
|
|
|
- closeNotify, err := node.NewNode(c.Gateway.Etcd...).Register(c.Gateway.ServerCode, mc.InterfaceToStr(c.Port))
|
|
|
+ closeNotify, err := node.NewNode(c.C.Gateway.Etcd...).Register(c.C.Gateway.ServerCode, mc.InterfaceToStr(c.C.Port))
|
|
|
if err != nil {
|
|
|
panic(err)
|
|
|
}
|
|
|
//
|
|
|
go func() {
|
|
|
- err := endless.ListenAndServe(":"+mc.InterfaceToStr(c.Webrpcport), nil, func() {})
|
|
|
+ err := endless.ListenAndServe(":"+mc.InterfaceToStr(c.C.Webrpcport), nil, func() {})
|
|
|
if err != nil {
|
|
|
log.Println("ListenAndServe: ", err)
|
|
|
}
|
|
|
}()
|
|
|
- ctx := svc.NewServiceContext(c)
|
|
|
- server := rest.MustNewServer(c.RestConf)
|
|
|
+ ctx := svc.NewServiceContext(c.C)
|
|
|
+ server := rest.MustNewServer(c.C.RestConf)
|
|
|
defer server.Stop()
|
|
|
|
|
|
handler.RegisterHandlers(server, ctx)
|
|
|
|
|
|
- fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port)
|
|
|
+ fmt.Printf("Starting server at %s:%d...\n", c.C.Host, c.C.Port)
|
|
|
server.Start()
|
|
|
|
|
|
quit := make(chan os.Signal, 1)
|