Graceful shut down server and vips

This commit is contained in:
DarthSim
2017-10-17 18:23:48 +06:00
parent 5b24ff905e
commit b8d655e1ba
4 changed files with 47 additions and 2 deletions

19
shutdown.go Normal file
View File

@@ -0,0 +1,19 @@
// +build go1.8
package main
import (
"context"
"log"
"net/http"
"time"
)
func shutdownServer(s *http.Server) {
log.Println("Shutting down the server...")
ctx, close := context.WithTimeout(context.Background(), 5*time.Second)
defer close()
s.Shutdown(ctx)
}