zhangqian
2024-07-03 f45e4cb8045fe60f96f467dc4ea1e2ae57445712
main.go
@@ -11,11 +11,16 @@
   "syscall"
   "time"
   "wms/conf"
   "wms/controllers"
   "wms/models"
   "wms/pkg/logx"
   "wms/proto/init_client"
   "wms/proto/inventory_order"
   "wms/proto/product_inventory"
   "wms/proto/purchase_wms"
   "wms/router"
   "wms/service"
   "wms/task"
   "wms/utils/dingtalkrobot"
)
func main() {
@@ -44,9 +49,12 @@
   }
   go shutdown(server)
   //启动grpc客户端
   go controllers.InitInventoryOrderServiceConn()
   go controllers.InitProductInventoryServiceConn()
   go controllers.InitCodeServiceConn()
   //go controllers.InitInventoryOrderServiceConn()
   //go controllers.InitProductInventoryServiceConn()
   //go controllers.InitCodeServiceConn()
   //go supplier.InitConn()
   //go client.InitConn()
   go init_client.InitClient()
   //启动grpc服务
   go func() {
      ln, err := net.Listen("tcp", ":"+conf.WebConf.GrpcPort)
@@ -54,16 +62,30 @@
         logx.Errorf("grpc server init error: %v", err.Error())
         panic(fmt.Sprintf("grpc server init error: %v", err.Error()))
      }
      fmt.Println("-----------监听端口: ", conf.WebConf.GrpcPort)
      s := grpc.NewServer()
      //todo 添加具体服务
      product_inventory.RegisterProductInventoryServiceServer(s, &product_inventory.Server{})
      purchase_wms.RegisterPurchaseServiceServer(s, &purchase_wms.Server{})
      inventory_order.RegisterInventoryOrderServiceServer(s, &inventory_order.Server{})
      err = s.Serve(ln)
      if err != nil {
         logx.Errorf("grpc server init error: %v", err.Error())
         panic(fmt.Sprintf("grpc server init error: %v", err.Error()))
      }
   }()
   go service.InitLocationReportData()
   go service.InitHistoryReportData()
   //定时任务初始化
   if err := task.Init(); err != nil {
      logx.Errorf("task init error: %v", err.Error())
      return
   }
   //钉钉机器人初始化
   dingtalkrobot.Init(conf.DingTalkConf.AlarmKey, conf.DingTalkConf.AlarmUrl)
   logx.Error(server.ListenAndServe().Error())
}
@@ -77,9 +99,12 @@
   ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
   defer cancel()
   controllers.CloseInventoryOrderServiceConn()
   controllers.CloseProductInventoryServiceConn()
   controllers.CloseCodeServiceConn()
   //controllers.CloseInventoryOrderServiceConn()
   //controllers.CloseProductInventoryServiceConn()
   //controllers.CloseCodeServiceConn()
   //supplier.CloseConn()
   //client.CloseConn()
   init_client.CloseClient()
   // 关闭HTTP服务器
   if err := server.Shutdown(ctx); err != nil {
      logx.Infof("服务优雅退出失败: %v", err)