| | |
| | | "wms/controllers" |
| | | "wms/models" |
| | | "wms/pkg/logx" |
| | | "wms/proto/client" |
| | | "wms/proto/product_inventory" |
| | | "wms/proto/purchase_wms" |
| | | "wms/proto/supplier" |
| | | "wms/router" |
| | | "wms/service" |
| | | ) |
| | | |
| | | func main() { |
| | |
| | | go controllers.InitInventoryOrderServiceConn() |
| | | go controllers.InitProductInventoryServiceConn() |
| | | go controllers.InitCodeServiceConn() |
| | | go supplier.InitConn() |
| | | go client.InitConn() |
| | | //启动grpc服务 |
| | | go func() { |
| | | ln, err := net.Listen("tcp", ":"+conf.WebConf.GrpcPort) |
| | |
| | | s := grpc.NewServer() |
| | | //todo 添加具体服务 |
| | | product_inventory.RegisterProductInventoryServiceServer(s, &product_inventory.Server{}) |
| | | purchase_wms.RegisterPurchaseServiceServer(s, &purchase_wms.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() |
| | | |
| | | logx.Error(server.ListenAndServe().Error()) |
| | | } |
| | | |
| | |
| | | controllers.CloseInventoryOrderServiceConn() |
| | | controllers.CloseProductInventoryServiceConn() |
| | | controllers.CloseCodeServiceConn() |
| | | supplier.CloseConn() |
| | | client.CloseConn() |
| | | // 关闭HTTP服务器 |
| | | if err := server.Shutdown(ctx); err != nil { |
| | | logx.Infof("服务优雅退出失败: %v", err) |