INNER CODE UNIT · Go

gracefulShutdown

sy-vendor/Gobi · cmd/server/main.go:255

func gracefulShutdown(srv *http.Server, timeout time.Duration) error {
	utils.Logger.Info("Shutting down server gracefully...")

	ctx, cancel := context.WithTimeout(context.Background(), timeout)
	defer cancel()

	if err := srv.Shutdown(ctx); err != nil {
		utils.Logger.WithError(err).Error("Server forced to shutdown")
		return err
	}

	utils.Logger.Info("Server exited gracefully")
	return nil
}

func main() {
	_ = godotenv.Load()

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…