diff --git a/main.go b/main.go index 49356f2..66a7371 100644 --- a/main.go +++ b/main.go @@ -8,6 +8,7 @@ import ( "os" "os/signal" "syscall" + "time" "git.vinchent.xyz/vinchent/go-web/framework" ) @@ -33,7 +34,9 @@ func main() { <-quit fmt.Println("YOLO") - if err := server.Shutdown(context.Background()); err != nil { + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + defer cancel() + if err := server.Shutdown(ctx); err != nil { log.Fatal("server shutdown: ", err) } }