Skip to content

Latest commit

 

History

History
43 lines (33 loc) · 1.21 KB

README.md

File metadata and controls

43 lines (33 loc) · 1.21 KB

Go Report Card PkgGoDev GitHub License GitHub tag (latest by date)

Grace HTTP Server Runner

A GRPC Server Runner for use with grace.

Usage

package main

import (
	"context"
	"github.com/tomwright/grace"
	"github.com/tomwright/gracehttpserverrunner"
	"net/http"
	"time"
)

func main() {
	g := grace.Init(context.Background())

	// Create and configure your HTTP server.
	server := &http.Server{
		Addr:    ":8080",
		Handler: http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) {}),
	}

	// Create and configure the HTTP server runner.
	runner := &gracehttpserverrunner.HTTPServerRunner{
		Server:  server,
		ShutdownTimeout: time.Second * 5,
	}

	// Run the runner.
	g.Run(runner)

	g.Wait()
}