zhangqian
2024-07-03 f45e4cb8045fe60f96f467dc4ea1e2ae57445712
main.go
@@ -11,16 +11,16 @@
   "syscall"
   "time"
   "wms/conf"
   "wms/controllers"
   "wms/models"
   "wms/pkg/logx"
   "wms/proto/client"
   "wms/proto/init_client"
   "wms/proto/inventory_order"
   "wms/proto/product_inventory"
   "wms/proto/purchase_wms"
   "wms/proto/supplier"
   "wms/router"
   "wms/service"
   "wms/task"
   "wms/utils/dingtalkrobot"
)
func main() {
@@ -49,11 +49,12 @@
   }
   go shutdown(server)
   //启动grpc客户端
   go controllers.InitInventoryOrderServiceConn()
   go controllers.InitProductInventoryServiceConn()
   go controllers.InitCodeServiceConn()
   go supplier.InitConn()
   go client.InitConn()
   //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)
@@ -61,7 +62,6 @@
         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{})
@@ -77,6 +77,15 @@
   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())
}
@@ -90,11 +99,12 @@
   ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
   defer cancel()
   controllers.CloseInventoryOrderServiceConn()
   controllers.CloseProductInventoryServiceConn()
   controllers.CloseCodeServiceConn()
   supplier.CloseConn()
   client.CloseConn()
   //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)