fermentord/cmd/fermentord/http.go
2022-07-24 00:50:16 +02:00

24 lines
483 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) {
hub := sentry.CurrentHub().Clone()
defer hub.Flush(10 * time.Second)
defer wg.Done()
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)
}
}