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() }) }