fermentord/cmd/fermentord/http.go
Søren Rasmussen 7f4718fabc
All checks were successful
continuous-integration/drone/push Build is passing
Add more error output
2022-07-25 10:55:25 +02:00

25 lines
484 B
Go

package main
import (
"context"
"log"
"net/http"
"sync"
"time"
"github.com/getsentry/sentry-go"
)
func shutdownHTTP(ctx context.Context, wg *sync.WaitGroup, srv *http.Server) {
defer wg.Done()
hub := sentry.CurrentHub().Clone()
defer hub.Flush(10 * time.Second)
ctx2, cancel := context.WithTimeout(ctx, 10*time.Second)
defer cancel()
if err := srv.Shutdown(ctx2); err != nil {
hub.CaptureException(err)
log.Printf("Error shutting down HTTP server: %v", err)
}
}