Skip to content

Commit

Permalink
remove graceful
Browse files Browse the repository at this point in the history
  • Loading branch information
fesiong committed Jan 20, 2021
1 parent 4fb3f9a commit 60bd9d1
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@ import (
"fmt"
"github.com/kataras/iris/v12"
"github.com/kataras/iris/v12/middleware/recover"
"github.com/rrylee/go-graceful"
"irisweb/config"
"irisweb/middleware"
"irisweb/model"
"irisweb/route"
"log"
"net"
"time"
)

Expand Down Expand Up @@ -55,20 +52,26 @@ func (bootstrap *Bootstrap) Serve() {
pugEngine.AddFunc("stampToDate", TimestampToDate)
bootstrap.Application.RegisterView(pugEngine)

grace := graceful.New()
grace.RegisterService(graceful.NewAddress(fmt.Sprintf("127.0.0.1:%d", bootstrap.Port), "tcp"), func(ln net.Listener) error {
return bootstrap.Application.Run(
iris.Listener(ln),
iris.WithoutServerError(iris.ErrServerClosed),
iris.WithoutBodyConsumptionOnUnmarshal,
)
}, func() error {
return bootstrap.Application.Shutdown(context.Background())
})
err := grace.Run()
if err != nil {
log.Fatal(err)
}
bootstrap.Application.Run(
iris.Addr(fmt.Sprintf(":%d", bootstrap.Port)),
iris.WithoutServerError(iris.ErrServerClosed),
iris.WithoutBodyConsumptionOnUnmarshal,
)

//grace := graceful.New()
//grace.RegisterService(graceful.NewAddress(fmt.Sprintf("127.0.0.1:%d", bootstrap.Port), "tcp"), func(ln net.Listener) error {
// return bootstrap.Application.Run(
// iris.Listener(ln),
// iris.WithoutServerError(iris.ErrServerClosed),
// iris.WithoutBodyConsumptionOnUnmarshal,
// )
//}, func() error {
// return bootstrap.Application.Shutdown(context.Background())
//})
//err := grace.Run()
//if err != nil {
// log.Fatal(err)
//}
}

func TimestampToDate(in int64, layout string) string {
Expand Down

0 comments on commit 60bd9d1

Please sign in to comment.