Skip to content

l-hellmann/sigterm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Sigterm

$ go get github.com/l-hellmann/sigterm

Usage

package main

import (
	"context"
	"fmt"
	"net/http"

	"github.com/l-hellmann/sigterm"
)

func main() {
	ctx := sigterm.Context()
	s := &http.Server{
		Addr: ":80",
		Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
			fmt.Fprintln(w, "hello world")
		}),
	}
	go func() {
		if err := s.ListenAndServe(); err != nil {
			panic(err)
		}
	}()
	<-ctx.Done()
	_ = s.Shutdown(context.Background())
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages