fix: refactor layout init

This commit is contained in:
ericprd
2025-02-26 22:28:19 +08:00
parent ba075b67fd
commit 0100134527
16 changed files with 154 additions and 39 deletions
+3 -2
View File
@@ -8,6 +8,7 @@ import (
"syscall"
"time"
"github.com/ardeman/project-legalgo-go/config"
"github.com/go-chi/chi/v5"
"github.com/sirupsen/logrus"
"golang.org/x/sync/errgroup"
@@ -28,14 +29,14 @@ func Router(apiRouter chi.Router) {
group, groupCtx := errgroup.WithContext(mainCtx)
group.Go(func() error {
logrus.Infof("Listening to port %d", APP_PORT)
logrus.Infof("Listening to port %d", config.APP_PORT)
return svr.ListenAndServe()
})
group.Go(func() error {
<-groupCtx.Done()
ctxTimeout, cancel := context.WithTimeout(mainCtx, GRACEFULL_TIMEOUT*time.Second)
ctxTimeout, cancel := context.WithTimeout(mainCtx, time.Duration(config.GRACEFULL_TIMEOUT)*time.Second)
defer cancel()
svr.Shutdown(ctxTimeout)