biservice.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // Code generated by goctl. DO NOT EDIT!
  2. // Source: biService.proto
  3. package main
  4. import (
  5. "bp.jydev.jianyu360.cn/BaseService/biService/entity"
  6. IC "bp.jydev.jianyu360.cn/BaseService/biService/rpc/internal/config"
  7. "bp.jydev.jianyu360.cn/BaseService/biService/rpc/internal/server"
  8. "bp.jydev.jianyu360.cn/BaseService/biService/rpc/internal/svc"
  9. "bp.jydev.jianyu360.cn/BaseService/biService/rpc/pb"
  10. "flag"
  11. "fmt"
  12. "github.com/nsqio/go-nsq"
  13. "github.com/zeromicro/go-zero/core/conf"
  14. "github.com/zeromicro/go-zero/core/logx"
  15. "github.com/zeromicro/go-zero/zrpc"
  16. "google.golang.org/grpc"
  17. )
  18. var configFile = flag.String("f", "etc/biservice.yaml", "the config file")
  19. func main() {
  20. flag.Parse()
  21. conf.MustLoad(*configFile, &IC.IC)
  22. ctx := svc.NewServiceContext(IC.IC)
  23. srv := server.NewBiServiceServer(ctx)
  24. logx.MustSetup(IC.IC.Logx)
  25. entity.PublicKey = IC.IC.PublicKey
  26. entity.InitMysql(IC.IC.Mysql.JianYu, IC.IC.Mysql.JyDoc, IC.IC.Mysql.Bi, IC.IC.Mysql.Tidb, IC.IC.Mysql.BiTidb, IC.IC.Mysql.CallTidb, IC.IC.Mysql.BiService)
  27. entity.InitMail(IC.IC.Mail)
  28. entity.InitMongo(IC.IC.Mongo.Qfw.MongodbAddr, IC.IC.Mongo.Qfw.DbName, IC.IC.Mongo.Qfw.Size)
  29. entity.InitBiddingMgo(IC.IC.Mongo.Bidding.MongodbAddr, IC.IC.Mongo.Bidding.DbName, IC.IC.Mongo.Bidding.UserName, IC.IC.Mongo.Bidding.Password, IC.IC.Mongo.Bidding.Size)
  30. entity.InitQyxyMgo(IC.IC.Mongo.Qyxy.MongodbAddr, IC.IC.Mongo.Qyxy.DbName, IC.IC.Mongo.Qyxy.UserName, IC.IC.Mongo.Qyxy.Password, IC.IC.Mongo.Qyxy.Size)
  31. entity.InitEs(IC.IC.Es.Version, IC.IC.Es.Address, IC.IC.Es.UserName, IC.IC.Es.Password, IC.IC.Es.DbSize)
  32. entity.InitEntEs(IC.IC.EntEs.Version, IC.IC.EntEs.Address, IC.IC.EntEs.UserName, IC.IC.EntEs.Password, IC.IC.EntEs.DbSize)
  33. entity.InitArea()
  34. entity.InitRedis(IC.IC.RedisAddress)
  35. entity.InitConfig(IC.IC.ExportDirectory, IC.IC.ComFileDir, IC.IC.UpdateProjectUrl, IC.IC.ExportUrl, IC.IC.ComFileUrl, IC.IC.ExportCount)
  36. //合力亿捷
  37. entity.GetHlyj(IC.IC.Hlyj.Appid, IC.IC.Hlyj.Account, IC.IC.Hlyj.Secret, IC.IC.Hlyj.TokenUrl, IC.IC.Hlyj.CallUrl, IC.IC.Hlyj.Integratedid, IC.IC.Hlyj.CallFlag)
  38. entity.InitMiddleground(IC.IC.RpcServerConf.Etcd.Hosts, IC.IC.ResourceCenterKey)
  39. //entity.FileCenterRpc = filecenter.NewFileCenter(zrpc.MustNewClient(IC.IC.FileCenterRpc))
  40. entity.OssBucketName = IC.IC.OssBucketName
  41. entity.OssUrl = IC.IC.OssUrl
  42. //nsq
  43. config := nsq.NewConfig()
  44. consumer, err := nsq.NewConsumer(IC.IC.TopicName, "jy_position_sync", config)
  45. if err != nil {
  46. fmt.Println(err)
  47. }
  48. consumer.AddHandler(&entity.Handler{})
  49. err = consumer.ConnectToNSQLookupd(IC.IC.NsqUrl)
  50. if err != nil {
  51. fmt.Println(err)
  52. }
  53. s := zrpc.MustNewServer(IC.IC.RpcServerConf, func(grpcServer *grpc.Server) {
  54. pb.RegisterBiServiceServer(grpcServer, srv)
  55. })
  56. defer s.Stop()
  57. fmt.Printf("Starting rpc server at %s...\n", IC.IC.ListenOn)
  58. s.Start()
  59. }