added an function to graceful shut down the server.
Dieser Commit ist enthalten in:
Ursprung
f2de0903cd
Commit
97307bc3d8
11
http.go
11
http.go
|
@ -1,8 +1,10 @@
|
|||
package httpserver
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/pelletier/go-toml"
|
||||
|
@ -91,6 +93,15 @@ func (s *Server) UseAuthBackend(a auth.AuthenticationHandler) {
|
|||
s.authhf = a
|
||||
}
|
||||
|
||||
// Stop Shuts the Server down
|
||||
func (s *Server) Stop() {
|
||||
ctx, _ := context.WithDeadline(context.Background(), time.Now().Add(time.Second*5))
|
||||
go func() {
|
||||
log.Info().Err(s.http.Shutdown(ctx)).Msg("Server Shut down.")
|
||||
}()
|
||||
<-ctx.Done()
|
||||
}
|
||||
|
||||
// Site is an Interface to abstract the modularized group of pages.
|
||||
// The Middleware must be able to detect multiple calls byy itself. Deduplication is not performed.
|
||||
type Site interface {
|
||||
|
|
Laden…
In neuem Issue referenzieren