package main import ( "flag" "fmt" "os" "os/signal" "syscall" "bp.jydev.jianyu360.cn/ApplicationCenter/threeMarket/api/internal/config" "bp.jydev.jianyu360.cn/ApplicationCenter/threeMarket/api/internal/handler" "bp.jydev.jianyu360.cn/ApplicationCenter/threeMarket/api/internal/svc" "bp.jydev.jianyu360.cn/ApplicationCenter/threeMarket/public/service" "bp.jydev.jianyu360.cn/ApplicationCenter/threeMarket/rpc/threemarket" "bp.jydev.jianyu360.cn/BaseService/gateway/core/node" "github.com/zeromicro/go-zero/core/conf" "github.com/zeromicro/go-zero/rest" "github.com/zeromicro/go-zero/zrpc" ) var configFile = flag.String("f", "etc/threemarket.yaml", "the config file") func main() { flag.Parse() var c config.Config conf.MustLoad(*configFile, &c) ctx := svc.NewServiceContext(c) server := rest.MustNewServer(c.RestConf) defer server.Stop() service.ThreemarketRpc = threemarket.NewThreeMarket(zrpc.MustNewClient(c.ThreeMarketRpcConf)) handler.RegisterHandlers(server, ctx) closeNotify, err := node.NewNode(c.GatewayRpcConf.Etcd.Hosts[0]).Register(c.ThreeMarketRpcConf.Etcd.Key, fmt.Sprint(c.Port)) if err != nil { panic(err) } fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port) go func() { server.Start() }() quit := make(chan os.Signal, 1) signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM) <-quit closeNotify() }