biservice.go 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. "bp.jydev.jianyu360.cn/BaseService/fileCenter/rpc/filecenter"
  11. "flag"
  12. "fmt"
  13. "github.com/nsqio/go-nsq"
  14. "github.com/zeromicro/go-zero/core/conf"
  15. "github.com/zeromicro/go-zero/core/logx"
  16. "github.com/zeromicro/go-zero/zrpc"
  17. "google.golang.org/grpc"
  18. )
  19. var configFile = flag.String("f", "etc/biservice.yaml", "the config file")
  20. func main() {
  21. flag.Parse()
  22. conf.MustLoad(*configFile, &IC.IC)
  23. ctx := svc.NewServiceContext(IC.IC)
  24. srv := server.NewBiServiceServer(ctx)
  25. logx.MustSetup(IC.IC.Logx)
  26. entity.PublicKey = IC.IC.PublicKey
  27. 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, IC.IC.Mysql.WorkOrder)
  28. entity.InitMail(IC.IC.Mail)
  29. entity.InitMongo(IC.IC.Mongo.Qfw.MongodbAddr, IC.IC.Mongo.Qfw.DbName, IC.IC.Mongo.Qfw.Size)
  30. 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)
  31. 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)
  32. entity.InitEs(IC.IC.Es.Version, IC.IC.Es.Address, IC.IC.Es.UserName, IC.IC.Es.Password, IC.IC.Es.DbSize)
  33. entity.InitEntEs(IC.IC.EntEs.Version, IC.IC.EntEs.Address, IC.IC.EntEs.UserName, IC.IC.EntEs.Password, IC.IC.EntEs.DbSize)
  34. entity.InitArea()
  35. entity.InitRedis(IC.IC.RedisAddress)
  36. entity.InitConfig(IC.IC.ExportDirectory, IC.IC.ComFileDir, IC.IC.UpdateProjectUrl, IC.IC.ExportUrl, IC.IC.ComFileUrl, IC.IC.ExportCount)
  37. //合力亿捷
  38. 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)
  39. entity.InitMiddleground(IC.IC.RpcServerConf.Etcd.Hosts, IC.IC.ResourceCenterKey)
  40. entity.FileCenterRpc = filecenter.NewFileCenter(zrpc.MustNewClient(IC.IC.FileCenterRpc))
  41. entity.OssBucketName = IC.IC.OssBucketName
  42. entity.OssUrl = IC.IC.OssUrl
  43. //nsq
  44. config := nsq.NewConfig()
  45. consumer, err := nsq.NewConsumer(IC.IC.TopicName, "jy_position_sync", config)
  46. if err != nil {
  47. fmt.Println(err)
  48. }
  49. consumer.AddHandler(&entity.Handler{})
  50. err = consumer.ConnectToNSQLookupd(IC.IC.NsqUrl)
  51. if err != nil {
  52. fmt.Println(err)
  53. }
  54. s := zrpc.MustNewServer(IC.IC.RpcServerConf, func(grpcServer *grpc.Server) {
  55. pb.RegisterBiServiceServer(grpcServer, srv)
  56. })
  57. defer s.Stop()
  58. fmt.Printf("Starting rpc server at %s...\n", IC.IC.ListenOn)
  59. s.Start()
  60. }