From ed48ec46a8157d4c817629a7cd90729693357677 Mon Sep 17 00:00:00 2001 From: Rogee Date: Mon, 22 Dec 2025 11:33:51 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BD=BF=E7=94=A8=20errgroup=20?= =?UTF-8?q?=E5=B9=B6=E5=8F=91=E5=A4=84=E7=90=86=20HTTP=20=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E5=92=8C=E4=BD=9C=E4=B8=9A=E5=90=AF=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend_v1/app/commands/http/http.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/backend_v1/app/commands/http/http.go b/backend_v1/app/commands/http/http.go index c7c96cd..d75ea92 100644 --- a/backend_v1/app/commands/http/http.go +++ b/backend_v1/app/commands/http/http.go @@ -23,6 +23,7 @@ import ( "go.ipao.vip/atom/container" "go.ipao.vip/atom/contracts" + "github.com/go-pay/errgroup" "github.com/gofiber/fiber/v3" "github.com/gofiber/fiber/v3/middleware/favicon" "github.com/rogeecn/fabfile" @@ -93,7 +94,23 @@ func Serve(cmd *cobra.Command, args []string) error { svc.Http.Engine.Get("/admin*", checkStaticFile(svc.App.DistAdmin)) svc.Http.Engine.Get("/*", checkStaticFile(svc.App.DistWeChat)) - return svc.Http.Serve(ctx) + var eg errgroup.Group + + eg.Go(func(ctx context.Context) error { + // river job + if err := svc.Job.Start(ctx); err != nil { + log.WithError(err).Error("job start failed") + return err + } + defer svc.Job.StopAndCancel(ctx) + return nil + }) + + eg.Go(func(ctx context.Context) error { + return svc.Http.Serve(ctx) + }) + + return eg.Wait() }) }