bicenter.go 991 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package main
  2. import (
  3. "app.yhyue.com/moapp/jybase/common"
  4. . "bp.jydev.jianyu360.cn/BaseService/biCenter/api/common"
  5. "bp.jydev.jianyu360.cn/BaseService/biCenter/api/internal/handler"
  6. "bp.jydev.jianyu360.cn/BaseService/biCenter/api/internal/svc"
  7. "bp.jydev.jianyu360.cn/BaseService/gateway/core/node"
  8. "flag"
  9. "fmt"
  10. "github.com/zeromicro/go-zero/rest"
  11. "os"
  12. "os/signal"
  13. "syscall"
  14. )
  15. var configFile = flag.String("f", "etc/bicenter.yaml", "the config file")
  16. func main() {
  17. //注册代理服务
  18. closeNotify, err := node.NewNode(C.Gateway.Etcd...).Register(C.Gateway.ServerCode, common.InterfaceToStr(C.Port))
  19. if err != nil {
  20. panic(err)
  21. }
  22. flag.Parse()
  23. server := rest.MustNewServer(C.RestConf)
  24. defer server.Stop()
  25. ctx := svc.NewServiceContext(C)
  26. handler.RegisterHandlers(server, ctx)
  27. fmt.Printf("Starting server at %s:%d...\n", C.Host, C.Port)
  28. server.Start()
  29. quit := make(chan os.Signal, 1)
  30. signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
  31. <-quit
  32. closeNotify()
  33. }